X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2Fevent_mgr.cxx;h=a62e83f91df7e26b94a7b42a2259eb02ef100b36;hb=f525a05be8be446f93b2ed386ab34c2e1efe5d61;hp=c7ea2ebd33a5efb0550e45197525187745088e20;hpb=755173bd2efd2bdef793857a575050be107bfb69;p=simgear.git diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index c7ea2ebd..a62e83f9 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -4,6 +4,10 @@ void SGEventMgr::add(SGCallback* cb, double interval, double delay, bool repeat, bool simtime) { + // Clamp the delay value to 1 usec, so that user code can use + // "zero" as a synonym for "next frame". + if(delay <= 0) delay = 0.000001; + SGTimer* t = new SGTimer; t->interval = interval; t->callback = cb; @@ -31,9 +35,10 @@ void SGTimer::run() void SGEventMgr::update(double delta_time_sec) { - _rtQueue.update(delta_time_sec); - if(!_freezeProp || _freezeProp->getBoolValue() == false) - _simQueue.update(delta_time_sec); + _simQueue.update(delta_time_sec); + + double rt = _rtProp ? _rtProp->getDoubleValue() : 0; + _rtQueue.update(rt); } //////////////////////////////////////////////////////////////////////// @@ -59,7 +64,14 @@ SGTimerQueue::SGTimerQueue(int size) SGTimerQueue::~SGTimerQueue() { + for(int i=0; i<_numEntries; i++) { + delete _table[i].timer; + _table[i].timer = 0; + } + _numEntries = 0; delete[] _table; + _table = 0; + _tableSize = 0; } void SGTimerQueue::update(double deltaSecs)