nsITimer : Callback does not get called

View: New views
2 Messages — Rating Filter:   Alert me  

nsITimer : Callback does not get called

by Bugzilla from nitram@lutken.dk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying the following:

void loadURITimeOut(nsITimer *aTimer, void* aClosure)
{
        printf("loadURITimeOut\n") ;
}



onLoadUri (.....)
{
        nsresult rv;
        nsCOMPtr<nsITimer> m_timer = do_CreateInstance("@mozilla.org/timer;
1", &rv);
        if (!NS_FAILED(rv)) {
                rv = m_timer->InitWithFuncCallback(loadURITimeOut, 0, 100,
nsITimer::TYPE_REPEATING_SLACK);
                if (NS_FAILED(rv)) {
                  printf("Error\n");
                }
        }
}


Everything seems fine. Except that the callback function never gets
called.
Do I need to initialize the timing system in some way or what am I
missing ?

-Martin














_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding

Re: nsITimer : Callback does not get called

by Bugzilla from nitram@lutken.dk :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

My mistake.

m_timer is a member variable. It is initialized in the class
constructor.

Doing:

 MyClass::onLoadUri(....)
{
        nsresult rv;
        nsCOMPtr<nsITimer> m_timer = do_CreateInstance("@mozilla.org/
timer;1", &rv);
}

Where I created a temporary with the same name as the member var is ..
well not what I wanted :-)
It works fine now. And for those interested in a complete example see
the file

"mozilla/layout/inspector/src/inSearchLoop.cpp" in the mozilla source
code.

-Martin



_______________________________________________
dev-embedding mailing list
dev-embedding@...
https://lists.mozilla.org/listinfo/dev-embedding