From 369e6b564f41591531bc877d7bfc8c4d1832827b Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 31 Dec 2012 17:39:52 +0000 Subject: [PATCH] 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. --- src/Instrumentation/gps.cxx | 2 +- src/Navaids/FlightPlan.cxx | 9 +++++++++ src/Navaids/FlightPlan.hxx | 5 +++-- src/Scripting/NasalPositioned.cxx | 5 +++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Instrumentation/gps.cxx b/src/Instrumentation/gps.cxx index 158b87c6c..21485d4eb 100644 --- a/src/Instrumentation/gps.cxx +++ b/src/Instrumentation/gps.cxx @@ -716,7 +716,7 @@ void GPS::routeManagerSequenced() if ((index < 0) || (index >= count)) { _currentWaypt=NULL; _prevWaypt=NULL; - SG_LOG(SG_INSTR, SG_ALERT, "GPS: malformed route, index=" << index); + // no active leg on the route return; } diff --git a/src/Navaids/FlightPlan.cxx b/src/Navaids/FlightPlan.cxx index b66108fbb..eda1e2db5 100644 --- a/src/Navaids/FlightPlan.cxx +++ b/src/Navaids/FlightPlan.cxx @@ -226,6 +226,9 @@ void FlightPlan::clear() } _legs.clear(); + if (_delegate) { + _delegate->runCleared(); + } unlockDelegate(); } @@ -1205,5 +1208,11 @@ void FlightPlan::Delegate::runCurrentWaypointChanged() if (_inner) _inner->runCurrentWaypointChanged(); currentWaypointChanged(); } + +void FlightPlan::Delegate::runCleared() +{ + if (_inner) _inner->runCleared(); + cleared(); +} } // of namespace flightgear diff --git a/src/Navaids/FlightPlan.hxx b/src/Navaids/FlightPlan.hxx index 3eeb02cf6..84944069a 100644 --- a/src/Navaids/FlightPlan.hxx +++ b/src/Navaids/FlightPlan.hxx @@ -104,7 +104,7 @@ public: virtual void departureChanged() { } virtual void arrivalChanged() { } virtual void waypointsChanged() { } - + virtual void cleared() { } virtual void currentWaypointChanged() { } protected: @@ -117,7 +117,8 @@ public: void runArrivalChanged(); void runWaypointsChanged(); void runCurrentWaypointChanged(); - + void runCleared(); + friend class FlightPlan; bool _deleteWithPlan; diff --git a/src/Scripting/NasalPositioned.cxx b/src/Scripting/NasalPositioned.cxx index 252342516..cfdadf68f 100644 --- a/src/Scripting/NasalPositioned.cxx +++ b/src/Scripting/NasalPositioned.cxx @@ -1772,6 +1772,11 @@ public: { callDelegateMethod("currentWaypointChanged"); } + + virtual void cleared() + { + callDelegateMethod("cleared"); + } private: void callDelegateMethod(const char* method)