From ed9764f92390ce4b11226d4d76dcdfa708eb9fcf Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 23 Jan 2014 12:49:39 +0000 Subject: [PATCH] Fix spurious event-mgr warnings - don't warn on removeTask if the event-manager was already shutdown, as happens during normal FG shutdown or reset. --- simgear/structure/event_mgr.cxx | 20 +++++++++++++++++++- simgear/structure/event_mgr.hxx | 3 ++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index c4518f12..503bd974 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -38,7 +38,8 @@ void SGTimer::run() (*callback)(); } -SGEventMgr::SGEventMgr() +SGEventMgr::SGEventMgr() : + _inited(false) { } @@ -54,8 +55,18 @@ void SGEventMgr::unbind() _rtProp.clear(); } +void SGEventMgr::init() +{ + if (_inited) { + SG_LOG(SG_GENERAL, SG_WARN, "duplicate init of SGEventMgr"); + } + _inited = true; +} + void SGEventMgr::shutdown() { + _inited = false; + _simQueue.clear(); _rtQueue.clear(); } @@ -70,6 +81,13 @@ void SGEventMgr::update(double delta_time_sec) void SGEventMgr::removeTask(const std::string& name) { + // due to the ordering of the event-mgr in FG, tasks can be removed + // after we are shutdown (and hence, have all been cleared). Guard + // against this so we don't generate warnings below. + if (!_inited) { + return; + } + SGTimer* t = _simQueue.findByName(name); if (t) { _simQueue.remove(t); diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx index 06e28ea5..699522b8 100644 --- a/simgear/structure/event_mgr.hxx +++ b/simgear/structure/event_mgr.hxx @@ -72,7 +72,7 @@ public: SGEventMgr(); ~SGEventMgr(); - virtual void init() {} + virtual void init(); virtual void update(double delta_time_sec); virtual void unbind(); virtual void shutdown(); @@ -130,6 +130,7 @@ private: SGPropertyNode_ptr _rtProp; SGTimerQueue _rtQueue; SGTimerQueue _simQueue; + bool _inited; }; #endif // _SG_EVENT_MGR_HXX -- 2.39.5