X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2Fevent_mgr.cxx;h=503bd974e7f9c551604c958787e5d191a9b09d0a;hb=f41b18f0649a50e179ba41383f4061e1878c4d4c;hp=c4518f124eea484e088d43be6685f05f5fd04a07;hpb=6527c6357bce570fc4d4aa7eb203ac7b1797eaaf;p=simgear.git 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);