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.