Core/EventProcessor: Check whether an event was aborted before aborting it.
* Fixes an assertion introduced in commit 1ad73212dca0cf. * Use itr = std::unordered_map<...>::erase for updating the iterator.
This commit is contained in:
1 parent
80d77dfb46
commit
a354feb48b
1 file changed
+20
-13
@@ -82,24 +82,31 @@ void EventProcessor::Update(uint32 p_time)
|
|||||||
|
|
||||||
void EventProcessor::KillAllEvents(bool force)
|
void EventProcessor::KillAllEvents(bool force)
|
||||||
{
|
{
|
||||||
// first, abort all existing events
|
for (auto itr = m_events.begin(); itr != m_events.end();)
|
||||||
for (EventList::iterator i = m_events.begin(); i != m_events.end();)
|
|
||||||
{
|
{
|
||||||
EventList::iterator i_old = i;
|
// Abort events which weren't aborted already
|
||||||
++i;
|
if (!itr->second->IsAborted())
|
||||||
|
|
||||||
i_old->second->SetAborted();
|
|
||||||
i_old->second->Abort(m_time);
|
|
||||||
if (force || i_old->second->IsDeletable())
|
|
||||||
{
|
{
|
||||||
delete i_old->second;
|
itr->second->SetAborted();
|
||||||
|
itr->second->Abort(m_time);
|
||||||
if (!force) // need per-element cleanup
|
|
||||||
m_events.erase (i_old);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip non-deletable events when we are
|
||||||
|
// not forcing the event cancellation.
|
||||||
|
if (!force && !itr->second->IsDeletable())
|
||||||
|
{
|
||||||
|
++itr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete itr->second;
|
||||||
|
|
||||||
|
if (force)
|
||||||
|
++itr; // Clear the whole container when forcing
|
||||||
|
else
|
||||||
|
itr = m_events.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// fast clear event list (in force case)
|
|
||||||
if (force)
|
if (force)
|
||||||
m_events.clear();
|
m_events.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user