fix erasing and processing time events
Stefan Schuermans

Stefan Schuermans commited on 2018-09-09 16:22:42
Showing 1 changed files, with 6 additions and 3 deletions.

... ...
@@ -133,9 +133,12 @@ void CallMgr::run()
133 133
 
134 134
       // call time callees
135 135
       TimeCallees::const_iterator itTC;
136
-      for (itTC = timeCallees.begin(); itTC != timeCallees.end(); ++itTC) {
137
-        m_timeCallees.erase(*itTC); // first remove request from callee map
138
-        (*itTC)->timeCall(); // then call callee
136
+      for (itTC = timeCallees.begin(); itTC != timeCallees.end(); ) {
137
+        TimeCallees::const_iterator itTCE = itTC; // save iterator for erase
138
+        TimeCallee *tc = *itTC; // save pointer to time callee for callback
139
+        itTC++; // advance loop iterator to next element
140
+        m_timeCallees.erase(*itTCE); // first remove request from callee map
141
+        tc->timeCall(); // then call callee
139 142
       }
140 143
 
141 144
     } // if timeout
142 145