diff --git a/toolkit/components/startup/public/nsIAppStartup.idl b/toolkit/components/startup/public/nsIAppStartup.idl index f9a3f585c156..25789971925f 100644 --- a/toolkit/components/startup/public/nsIAppStartup.idl +++ b/toolkit/components/startup/public/nsIAppStartup.idl @@ -41,7 +41,7 @@ interface nsICmdLineService; -[scriptable, uuid(e9b0f89b-0529-4d96-98a8-eb5b2b9a8383)] +[scriptable, uuid(6799abed-4721-4f51-9304-d1a2ea1df5d5)] interface nsIAppStartup : nsISupports { /** @@ -49,6 +49,12 @@ interface nsIAppStartup : nsISupports */ void createHiddenWindow(); + /** + * Destroys the hidden window. This will have no effect if the hidden window + * has not yet been created. + */ + void destroyHiddenWindow(); + /** * Runs an application event loop: normally the main event pump which * defines the lifetime of the application. If there are no windows open diff --git a/toolkit/components/startup/src/nsAppStartup.cpp b/toolkit/components/startup/src/nsAppStartup.cpp index 667e6d0340a6..e62fbb585904 100644 --- a/toolkit/components/startup/src/nsAppStartup.cpp +++ b/toolkit/components/startup/src/nsAppStartup.cpp @@ -150,6 +150,17 @@ nsAppStartup::CreateHiddenWindow() } +NS_IMETHODIMP +nsAppStartup::DestroyHiddenWindow() +{ + nsCOMPtr appShellService + (do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); + NS_ENSURE_TRUE(appShellService, NS_ERROR_FAILURE); + + return appShellService->DestroyHiddenWindow(); +} + + NS_IMETHODIMP nsAppStartup::Run(void) { @@ -300,12 +311,6 @@ nsAppStartup::Quit(PRUint32 aMode) mRestart ? restartStr.get() : shutdownStr.get()); } - nsCOMPtr appShellService - (do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); - NS_ASSERTION(appShellService, "We're gonna leak something."); - if (appShellService) - appShellService->DestroyHiddenWindow(); - if (!mRunning) { postedExitEvent = PR_TRUE; } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 838e827c53ae..4b8b81797215 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -850,6 +850,10 @@ private: ScopedXPCOMStartup::~ScopedXPCOMStartup() { if (mServiceManager) { + nsCOMPtr appStartup (do_GetService(NS_APPSTARTUP_CONTRACTID)); + if (appStartup) + appStartup->DestroyHiddenWindow(); + gDirServiceProvider->DoShutdown(); WriteConsoleLog(); @@ -3182,12 +3186,6 @@ XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) #ifdef XP_MACOSX SetupMacCommandLine(gRestartArgc, gRestartArgv); #endif - - // Ensure hidden window is destroyed before xpcom shuts down - nsCOMPtr appShellService - (do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); - if (appShellService) - appShellService->DestroyHiddenWindow(); } } }