mirror of https://github.com/ARMmbed/mbed-os.git
Fix fake event queue process event.
The result of remove_if was fed into erase without checking something was actually removed.pull/14254/head
parent
0feaae6d18
commit
a3a507d9ca
|
@ -98,21 +98,22 @@ void EventQueue::process_events() {
|
|||
}
|
||||
|
||||
/* dispatch all handlers that happen at this time */
|
||||
_handlers.erase(
|
||||
std::remove_if(
|
||||
_handlers.begin(),
|
||||
_handlers.end(),
|
||||
[earliest_tick](internal_event& element) -> bool {
|
||||
if (earliest_tick >= element.tick) {
|
||||
(*(element.handler))();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
auto found = std::remove_if(
|
||||
_handlers.begin(),
|
||||
_handlers.end(),
|
||||
[earliest_tick](internal_event& element) -> bool {
|
||||
if (earliest_tick >= element.tick) {
|
||||
(*(element.handler))();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
),
|
||||
_handlers.end()
|
||||
}
|
||||
);
|
||||
|
||||
if (found != _handlers.end()) {
|
||||
_handlers.erase(found, _handlers.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue