Futile icon indicating copy to clipboard operation
Futile copied to clipboard

Stoping a delayed callback inside a callback can make weird things

Open jpsarda opened this issue 10 years ago • 1 comments

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

jpsarda avatar Apr 25 '14 20:04 jpsarda

Cool, makes sense, yup I'll put a fix in for it...

MattRix avatar Apr 25 '14 21:04 MattRix