X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2Fevent_mgr.cxx;h=d4b573d00e84ea674529f5b22c32dac8401f8d37;hb=7dfb463ba9ac50e890718612cd6b55373b7cc4a8;hp=c7ea2ebd33a5efb0550e45197525187745088e20;hpb=755173bd2efd2bdef793857a575050be107bfb69;p=simgear.git diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index c7ea2ebd..d4b573d0 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -1,9 +1,15 @@ #include "event_mgr.hxx" +#include + 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 +37,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 +66,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)