diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index 2e4f7b78..d5ffd01e 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -10,6 +10,11 @@ void SGEventMgr::add(const std::string& name, SGCallback* cb, double interval, double delay, bool repeat, bool simtime) { + // Prevent Nasal from attempting to add timers after the subsystem has been + // shut down. + if (_shutdown) + return; + // Clamp the delay value to 1 usec, so that user code can use // "zero" as a synonym for "next frame". if(delay <= 0) delay = 1e-6; @@ -39,14 +44,15 @@ void SGTimer::run() } SGEventMgr::SGEventMgr() : - _inited(false) + _inited(false), + _shutdown(false) { } SGEventMgr::~SGEventMgr() { - + _shutdown = true; } void SGEventMgr::unbind() @@ -69,7 +75,8 @@ void SGEventMgr::init() void SGEventMgr::shutdown() { _inited = false; - + _shutdown = true; + _simQueue.clear(); _rtQueue.clear(); } diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx index 699522b8..41dc7b86 100644 --- a/simgear/structure/event_mgr.hxx +++ b/simgear/structure/event_mgr.hxx @@ -130,7 +130,7 @@ private: SGPropertyNode_ptr _rtProp; SGTimerQueue _rtQueue; SGTimerQueue _simQueue; - bool _inited; + bool _inited, _shutdown; }; #endif // _SG_EVENT_MGR_HXX