1
0
Fork 0

Work-around for bug 1134, crash with flightplans.

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.
This commit is contained in:
James Turner 2013-07-17 20:26:34 +01:00
parent 63f19db028
commit 74e60df295

View file

@ -272,12 +272,22 @@ int FlightPlan::clearWayptsWithFlag(WayptFlag flag)
// test if the current leg will be removed // test if the current leg will be removed
bool currentIsBeingCleared = false; bool currentIsBeingCleared = false;
if (_currentIndex >= 0) { Leg* curLeg = currentLeg();
currentIsBeingCleared = _legs[_currentIndex]->waypoint()->flag(flag); if (curLeg) {
currentIsBeingCleared = curLeg->waypoint()->flag(flag);
} }
_currentIndex -= count; _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 // now delete and remove
RemoveWithFlag rf(flag); RemoveWithFlag rf(flag);
LegVec::iterator it = std::remove_if(_legs.begin(), _legs.end(), rf); LegVec::iterator it = std::remove_if(_legs.begin(), _legs.end(), rf);