From: James Turner Date: Tue, 12 Nov 2013 22:20:21 +0000 (+0000) Subject: Reset: clean event-manager shutdown X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6527c6357bce570fc4d4aa7eb203ac7b1797eaaf;p=simgear.git Reset: clean event-manager shutdown --- diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index 37ef4e13..c4518f12 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -54,6 +54,12 @@ void SGEventMgr::unbind() _rtProp.clear(); } +void SGEventMgr::shutdown() +{ + _simQueue.clear(); + _rtQueue.clear(); +} + void SGEventMgr::update(double delta_time_sec) { _simQueue.update(delta_time_sec); @@ -97,7 +103,7 @@ SGTimerQueue::SGTimerQueue(int size) _table = new HeapEntry[_tableSize]; for(int i=0; i<_tableSize; i++) { - _table[i].pri = 0; + _table[i].pri = 0; _table[i].timer = 0; } } @@ -105,14 +111,24 @@ SGTimerQueue::SGTimerQueue(int size) SGTimerQueue::~SGTimerQueue() { + clear(); + delete[] _table; +} + +void SGTimerQueue::clear() +{ + // delete entries for(int i=0; i<_numEntries; i++) { delete _table[i].timer; - _table[i].timer = 0; } + _numEntries = 0; - delete[] _table; - _table = 0; - _tableSize = 0; + + // clear entire table to empty + for(int i=0; i<_tableSize; i++) { + _table[i].pri = 0; + _table[i].timer = 0; + } } void SGTimerQueue::update(double deltaSecs) diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx index 682964d2..06e28ea5 100644 --- a/simgear/structure/event_mgr.hxx +++ b/simgear/structure/event_mgr.hxx @@ -25,6 +25,7 @@ public: SGTimerQueue(int preSize=1); ~SGTimerQueue(); + void clear(); void update(double deltaSecs); double now() { return _now; } @@ -74,6 +75,7 @@ public: virtual void init() {} virtual void update(double delta_time_sec); virtual void unbind(); + virtual void shutdown(); void setRealtimeProperty(SGPropertyNode* node) { _rtProp = node; }