]> git.mxchange.org Git - simgear.git/blobdiff - simgear/structure/event_mgr.cxx
Minor compiler version detection issue.
[simgear.git] / simgear / structure / event_mgr.cxx
index 6753a38f41de7cf5b22e0b3160911cefb9441f6e..63e4672faaeb0a95212cb39760af5925dc050619 100644 (file)
@@ -14,9 +14,7 @@ void SGEventMgr::add(const std::string& name, SGCallback* cb,
     SGTimer* t = new SGTimer;
     t->interval = interval;
     t->callback = cb;
-    t->mgr = this;
     t->repeat = repeat;
-    t->simtime = simtime;
     t->name = name;
     
     SGTimerQueue* q = simtime ? &_simQueue : &_rtQueue;
@@ -24,17 +22,15 @@ void SGEventMgr::add(const std::string& name, SGCallback* cb,
     q->insert(t, delay);
 }
 
+SGTimer::~SGTimer()
+{
+    delete callback;
+    callback = NULL;
+}
+
 void SGTimer::run()
 {
     (*callback)();
-
-    if(repeat) {
-        SGTimerQueue* q = simtime ? &mgr->_simQueue : &mgr->_rtQueue;
-        q->insert(this, interval);
-    } else {
-        delete callback;
-        delete this;
-    }
 }
 
 void SGEventMgr::update(double delta_time_sec)
@@ -99,6 +95,11 @@ void SGTimerQueue::update(double deltaSecs)
     while(_numEntries && nextTime() <= _now) {
         SGTimer* t = remove();
         t->run();
+        if(t->repeat) {
+            insert(t, t->interval);
+        } else {
+            delete t;
+        }
     }
 }
 
@@ -193,4 +194,3 @@ SGTimer* SGTimerQueue::findByName(const std::string& name) const
   
   return NULL;
 }
-