1
0
Fork 0

Flightplan delegate hook for clearing the FP.

This allows delegates to take action when the flightlan is cleared, and especially, for the default delegate in the route-manager to deactivate itself, and hence the GPS LEG mode - which fixes bug 940 I hope.
This commit is contained in:
James Turner 2012-12-31 17:39:52 +00:00
parent 5ff8311acc
commit 369e6b564f
4 changed files with 18 additions and 3 deletions

View file

@ -716,7 +716,7 @@ void GPS::routeManagerSequenced()
if ((index < 0) || (index >= count)) { if ((index < 0) || (index >= count)) {
_currentWaypt=NULL; _currentWaypt=NULL;
_prevWaypt=NULL; _prevWaypt=NULL;
SG_LOG(SG_INSTR, SG_ALERT, "GPS: malformed route, index=" << index); // no active leg on the route
return; return;
} }

View file

@ -226,6 +226,9 @@ void FlightPlan::clear()
} }
_legs.clear(); _legs.clear();
if (_delegate) {
_delegate->runCleared();
}
unlockDelegate(); unlockDelegate();
} }
@ -1205,5 +1208,11 @@ void FlightPlan::Delegate::runCurrentWaypointChanged()
if (_inner) _inner->runCurrentWaypointChanged(); if (_inner) _inner->runCurrentWaypointChanged();
currentWaypointChanged(); currentWaypointChanged();
} }
void FlightPlan::Delegate::runCleared()
{
if (_inner) _inner->runCleared();
cleared();
}
} // of namespace flightgear } // of namespace flightgear

View file

@ -104,7 +104,7 @@ public:
virtual void departureChanged() { } virtual void departureChanged() { }
virtual void arrivalChanged() { } virtual void arrivalChanged() { }
virtual void waypointsChanged() { } virtual void waypointsChanged() { }
virtual void cleared() { }
virtual void currentWaypointChanged() { } virtual void currentWaypointChanged() { }
protected: protected:
@ -117,7 +117,8 @@ public:
void runArrivalChanged(); void runArrivalChanged();
void runWaypointsChanged(); void runWaypointsChanged();
void runCurrentWaypointChanged(); void runCurrentWaypointChanged();
void runCleared();
friend class FlightPlan; friend class FlightPlan;
bool _deleteWithPlan; bool _deleteWithPlan;

View file

@ -1772,6 +1772,11 @@ public:
{ {
callDelegateMethod("currentWaypointChanged"); callDelegateMethod("currentWaypointChanged");
} }
virtual void cleared()
{
callDelegateMethod("cleared");
}
private: private:
void callDelegateMethod(const char* method) void callDelegateMethod(const char* method)