]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/event_mgr.cxx
Improve (mostly Canvas event related) documentation.
[simgear.git] / simgear / structure / event_mgr.cxx
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);