Futile
Futile copied to clipboard
Stoping a delayed callback inside a callback can make weird things
If you stop a delayed while callback are processed, it changes the array that is currently browsed and can make weird things or crashes.
My solution was to postpone the removing of the delayed call back like this
public void StopDelayedCall(Action func)
{
int count = _delayedCallbacks.Count;
for (int d = 0; d<count; d++)
{
FDelayedCallback call = _delayedCallbacks[d];
if(call.func == func)
{
_delayedCallbacksToRemove.Add(call);
}
}
}
private void ProcessDelayedCallbacks()
{
foreach (FDelayedCallback callToRemove in _delayedCallbacksToRemove) {
_delayedCallbacks.Remove(callToRemove);
}
// ... same code after this
Cool, makes sense, yup I'll put a fix in for it...