Skip to content

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

Description

@gnunn1

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;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions