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

glib.Timeout warning "Source ID XXX was not found when attempting to remove it" #154

Closed
gnunn1 opened this Issue May 29, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@gnunn1
Contributor

gnunn1 commented May 29, 2016

I'm trying glib.Timeout for the first time, I have a delegate attached that returns false when a set of conditions is met. This all works fine, however I notice I get a warning when calling stop when the delegate returns false as follows:

Source ID XXX was not found when attempting to remove it

I'm thinking the method callAllListeners should set the timerID to 0 if all delegates are removed. I've tried this locally and it seems to resolve the problem:

    private bool callAllListeners()
    {
        bool runAgain = false;

        int i = 0;

        while ( i<timeoutListeners.length )
        {
            if ( !timeoutListeners[i]() )
            {
                timeoutListeners = timeoutListeners[0..i] ~ timeoutListeners[i+1..timeoutListeners.length];
            }
            else
            {
                runAgain = true;
                ++i;
            }
        }
        // GBN - Set timeoutID to 0 if all delegates are removed
        if (timeoutListeners.length == 0) timeoutID = 0;
        return runAgain;
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment