1
0
Fork 0

Fix FGAIFlightPlan waypoint issues

Iterator must be reset after clearing waypoint list.
Deleting "*waypoint.end()" doesn't delete the last waypoint (end()-1
does - it is never actually used though).
This commit is contained in:
ThorstenB 2012-11-27 21:02:32 +01:00
parent 4b8e0740c4
commit a28fe51ccf

View file

@ -291,6 +291,7 @@ void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
if (wpt_iterator == waypoints.begin())
wpt_iterator++;
else
if (!waypoints.empty())
{
delete *(waypoints.begin());
waypoints.erase(waypoints.begin());
@ -300,7 +301,6 @@ void FGAIFlightPlan::IncrementWaypoint(bool eraseWaypoints )
}
else
wpt_iterator++;
}
void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
@ -310,9 +310,10 @@ void FGAIFlightPlan::DecrementWaypoint(bool eraseWaypoints )
if (wpt_iterator == waypoints.end())
wpt_iterator--;
else
if (!waypoints.empty())
{
delete *(waypoints.end());
waypoints.erase(waypoints.end());
delete *(waypoints.end()-1);
waypoints.erase(waypoints.end()-1);
wpt_iterator = waypoints.end();
wpt_iterator--;
}
@ -397,6 +398,7 @@ void FGAIFlightPlan::deleteWaypoints()
for (wpt_vector_iterator i = waypoints.begin(); i != waypoints.end();i++)
delete (*i);
waypoints.clear();
wpt_iterator = waypoints.begin();
}
// Delete all waypoints except the last,