Ensure timers are still alive when trying to run them

This commit is contained in:
Maxime Coste 2016-12-06 13:55:53 +00:00
parent b3ac733f33
commit e9349cdc92

View File

@ -133,9 +133,10 @@ void EventManager::handle_next_events(EventMode mode, sigset_t* sigmask)
}
TimePoint now = Clock::now();
for (auto& timer : m_timers)
auto timers = m_timers; // copy timers in case m_timers gets mutated
for (auto& timer : timers)
{
if (timer->next_date() <= now)
if (contains(m_timers, timer) and timer->next_date() <= now)
timer->run(mode);
}
}