Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

getVisibleEngines fails if called too early on Firefox startup

26 views
Skip to first unread message

pete...@gmail.com

unread,
Apr 10, 2013, 4:51:38 AM4/10/13
to
On load event of a Firefox window I start listening for the "browser-delayed-startup-finished" notification, then I run a function that includes a call of getVisibleEngines({ }) of nsIBrowserSearchService. This call still sometimes fails, unless it is called after a delay.

Is there a less ugly way of doing this than using a delay?

Neil

unread,
Apr 10, 2013, 5:17:52 AM4/10/13
to
pete...@gmail.com wrote:

>On load event of a Firefox window I start listening for the "browser-delayed-startup-finished" notification, then I run a function that includes a call of getVisibleEngines({ }) of nsIBrowserSearchService. This call still sometimes fails, unless it is called after a delay.
>
>Is there a less ugly way of doing this than using a delay?
>
>
Have you tried calling init() and passing an observer whose
onInitComplete method includes the call of getVisibleEngines?

--
Warning: May contain traces of nuts.

pete...@gmail.com

unread,
Apr 10, 2013, 11:15:24 AM4/10/13
to
Dne sreda, 10. april 2013 11:17:52 UTC+2 je oseba Neil napisala:
Thanks for the answer, but could you be a bit more descriptive?
How do I make the observer? And how will I get the return value of getVisibleEngines?

Thank you.

Neil

unread,
Apr 10, 2013, 12:23:20 PM4/10/13
to
pete...@gmail.com wrote:

>Neil wrote:
>
>
>>pete...@gmail.com wrote:
>>
>>>On load event of a Firefox window I start listening for the "browser-delayed-startup-finished" notification, then I run a function that includes a call of getVisibleEngines({ }) of nsIBrowserSearchService. This call still sometimes fails, unless it is called after a delay.
>>>
>>>
>>>Is there a less ugly way of doing this than using a delay?
>>>
>>>
>>Have you tried calling init() and passing an observer whose
>>
>>onInitComplete method includes the call of getVisibleEngines?
>>
>>
>Thanks for the answer, but could you be a bit more descriptive?
>How do I make the observer? And how will I get the return value of getVisibleEngines?
>
>
Actually I misread the code and the process is slightly easier than that.

Supposing your old code looks something like this:
if (aTopic == "browser-delayed-startup-finished")
processVisibleEngines();

Then change it to
if (aTopic == "browser-delayed-startup-finished")
Services.search.init(processVisibleEngines);

Alternatively, if it looks something like this:
if (aTopic == "browser-delayed-startup-finished")
this.processVisibleEngines();

Then change it to
if (aTopic == "browser-delayed-startup-finished")
Services.search.init(this);

and rename processVisibleEngines to onInitComplete.

However note that onInitComplete/processVisibleEngines will be passed an
integer and you should use Components.isSuccessCode to ensure that the
initialisation succeeded.

pete...@gmail.com

unread,
Apr 10, 2013, 5:36:26 PM4/10/13
to
Dne sreda, 10. april 2013 18:23:20 UTC+2 je oseba Neil napisala:
That's how I can call a void function. But how do I get the return value out of the init()?

Neil

unread,
Apr 11, 2013, 4:52:52 AM4/11/13
to
pete...@gmail.com wrote:

>That's how I can call a void function. But how do I get the return value out of the init()?
>
>
You put *all* of the code in the void function, so you don't need a
return value.

pete...@gmail.com

unread,
Apr 11, 2013, 12:05:26 PM4/11/13
to
Dne četrtek, 11. april 2013 10:52:52 UTC+2 je oseba Neil napisala:
It works nicely now, thank you very much. :D
0 new messages