Scheduler: fix invalidated iterator access in `unscheduleAllWithMinPriority()`

This commit is contained in:
roman.semenov 2024-08-30 16:07:04 +03:00 committed by halx99
parent 5d6ab4eccb
commit 4644b2b428
1 changed files with 10 additions and 4 deletions

View File

@ -500,9 +500,11 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority)
unscheduleAllForTarget(timerIt);
}
axstd::pod_vector<void*> targets;
for (auto&& entry : _waitList)
{
unscheduleUpdate(entry->target);
targets.push_back(entry->target);
}
// Updates selectors
@ -512,7 +514,7 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority)
{
if (entry->priority >= minPriority)
{
unscheduleUpdate(entry->target);
targets.push_back(entry->target);
}
}
}
@ -521,7 +523,7 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority)
{
for (auto&& entry : _updates0List)
{
unscheduleUpdate(entry->target);
targets.push_back(entry->target);
}
}
@ -529,9 +531,13 @@ void Scheduler::unscheduleAllWithMinPriority(int minPriority)
{
if (entry->priority >= minPriority)
{
unscheduleUpdate(entry->target);
targets.push_back(entry->target);
}
}
for (auto target: targets)
unscheduleUpdate(target);
#if AX_ENABLE_SCRIPT_BINDING
_scriptHandlerEntries.clear();
#endif