]> git.mxchange.org Git - flightgear.git/commitdiff
Work-around for bug 1134, crash with flightplans.
authorJames Turner <zakalawe@mac.com>
Wed, 17 Jul 2013 19:26:34 +0000 (20:26 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 17 Jul 2013 19:26:48 +0000 (20:26 +0100)
When the active waypoint is deleted, and we can't offset the waypoint,
simply switch to the inactive waypoint. This is not ideal but avoids
the crash.

src/Navaids/FlightPlan.cxx

index 2087d5cc1fb165c1efb6b0f990ad05811854ef6f..5b190e97270c5059ae90a37027d326e1a0232a98 100644 (file)
@@ -269,14 +269,24 @@ int FlightPlan::clearWayptsWithFlag(WayptFlag flag)
       ++count;
     }
   }
-  
+
   // test if the current leg will be removed
   bool currentIsBeingCleared = false;
-  if (_currentIndex >= 0) {
-    currentIsBeingCleared = _legs[_currentIndex]->waypoint()->flag(flag);
+  Leg* curLeg = currentLeg();
+  if (curLeg) {
+    currentIsBeingCleared = curLeg->waypoint()->flag(flag);
   }
   
   _currentIndex -= count;
+    
+    // if we're clearing the current waypoint, what shall we do with the
+    // index? there's various options, but safest is to select no waypoint
+    // and let the use re-activate.
+    // http://code.google.com/p/flightgear-bugs/issues/detail?id=1134
+    if (currentIsBeingCleared) {
+        SG_LOG(SG_GENERAL, SG_INFO, "currentIsBeingCleared:" << currentIsBeingCleared);
+        _currentIndex = -1;
+    }
   
 // now delete and remove
   RemoveWithFlag rf(flag);