]> git.mxchange.org Git - flightgear.git/commitdiff
Fix route manager exception and following crash (may fix #177)
authorThorstenB <brehmt@gmail.com>
Sat, 27 Nov 2010 19:05:28 +0000 (20:05 +0100)
committerThorstenB <brehmt@gmail.com>
Sat, 27 Nov 2010 19:05:28 +0000 (20:05 +0100)
See bug issue #177 for more.
Also fix minor compiler warning.

src/Autopilot/route_mgr.cxx

index d5411b8af7d73960644590d5d37714e423d007f4..c0f8f26318f33315e505199b9892e8b0855f2344 100644 (file)
@@ -673,7 +673,7 @@ void FGRouteMgr::insertWayptAtIndex(Waypt* aWpt, int aIndex)
   }
   
   int index = aIndex;
-  if ((aIndex == -1) || (aIndex > _route.size())) {
+  if ((aIndex == -1) || (aIndex > (int) _route.size())) {
     index = _route.size();
   }
   
@@ -1027,7 +1027,7 @@ void FGRouteMgr::jumpToIndex(int index)
 
 void FGRouteMgr::currentWaypointChanged()
 {
-  Waypt* cur = currentWaypt();
+  Waypt* cur = (_currentIndex<numWaypts()) ? currentWaypt() : NULL;
   Waypt* next = nextWaypt();
 
   wp0->getChild("id")->setStringValue(cur ? cur->ident() : "");