]> git.mxchange.org Git - simgear.git/commitdiff
Fix spurious event-mgr warnings
authorJames Turner <zakalawe@mac.com>
Thu, 23 Jan 2014 12:49:39 +0000 (12:49 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 23 Jan 2014 12:49:39 +0000 (12:49 +0000)
- 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
simgear/structure/event_mgr.hxx

index c4518f124eea484e088d43be6685f05f5fd04a07..503bd974e7f9c551604c958787e5d191a9b09d0a 100644 (file)
@@ -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);
index 06e28ea58b91bdbb65eb27a571a460e34e817ce9..699522b8082ef5ba3d5c3c9743ed15b0cfd68a03 100644 (file)
@@ -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