| tqh ( @ 2004-05-14 21:02:00 |
Close All ( or the Almost there update) (or the How I learnt to use the nsIProxyObjectManager)
In Deskbar there is a, for Mozilla, little used menuitem called 'Close All'. Well not anymore. In my current build 'Close all' actually closes all the browser windows. Cleanly I might add, although it doesn't ask any questions first.
The reason it hasn't worked before is because of threading issues. So the main Mozilla thread doesn't agree with any outsider thread telling them to quit. But if a friendly Mozilla UI thread tells it to quit it does.
That's what the proxy does for us. Hopefully it will also do wonders for opening windows and embeddign. QuitRequested below...
In Deskbar there is a, for Mozilla, little used menuitem called 'Close All'. Well not anymore. In my current build 'Close all' actually closes all the browser windows. Cleanly I might add, although it doesn't ask any questions first.
The reason it hasn't worked before is because of threading issues. So the main Mozilla thread doesn't agree with any outsider thread telling them to quit. But if a friendly Mozilla UI thread tells it to quit it does.
That's what the proxy does for us. Hopefully it will also do wonders for opening windows and embeddign. QuitRequested below...
virtual bool QuitRequested() {
nsresult rv;
nsCOMPtr appShellServ = do_GetService(kAppShellServiceCID, &rv);
if(NS_FAILED(rv)) return false;
nsCOMPtr pIProxyObjectManager = do_GetService(kProxyObjectManagerCID, &rv);
if(NS_FAILED(rv)) return false;
nsCOMPtr appShellProxy;
rv = pIProxyObjectManager->GetProxyForObject(NS_UI_THREAD_EVENTQ, NS_GET_IID(nsIAppShellService), appShellServ, PROXY_ASYNC | PROXY_ALWAYS, getter_AddRefs(appShellProxy));
if(NS_FAILED(rv)) return false;
(void) appShellProxy->Quit(nsIAppShellService::eAttemptQuit);
}