Skip to content

Stoping a delayed callback inside a callback can make weird things #231

@jpsarda

Description

@jpsarda

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions