Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jpsarda opened this issue Apr 25, 2014 · 1 comment
Open

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

jpsarda opened this issue Apr 25, 2014 · 1 comment

Comments

@jpsarda
Copy link
Contributor

jpsarda commented Apr 25, 2014

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
@MattRix
Copy link
Owner

MattRix commented Apr 25, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants