diff --git a/mozilla/xpfe/appshell/public/nsIAppShellService.idl b/mozilla/xpfe/appshell/public/nsIAppShellService.idl index 7ffafd2b73c..3a0bea12643 100644 --- a/mozilla/xpfe/appshell/public/nsIAppShellService.idl +++ b/mozilla/xpfe/appshell/public/nsIAppShellService.idl @@ -59,8 +59,11 @@ interface nsIAppShellService : nsISupports */ void Run(); + +// Exit the event loop + void Quit(); /** - * Required exit routine. Stops the event loop and cleanly shuts down + * Required exit routine. Cleanly shuts down * the appshell components. */ void Shutdown(); diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 90168c6c266..24a1b6c1d35 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -122,6 +122,7 @@ protected: nsIWindowMediator* mWindowMediator; nsCOMPtr mHiddenWindow; PRBool mDeleteCalled; + PRBool mQuiting; }; nsAppShellService::nsAppShellService() : mWindowMediator( NULL ) @@ -132,6 +133,7 @@ nsAppShellService::nsAppShellService() : mWindowMediator( NULL ) mWindowList = nsnull; mCmdLineService = nsnull; mDeleteCalled = PR_FALSE; + mQuiting = PR_FALSE; } nsAppShellService::~nsAppShellService() @@ -453,20 +455,14 @@ nsAppShellService::Run(void) return mAppShell->Run(); } -NS_IMETHODIMP -nsAppShellService::Shutdown(void) + +NS_IMETHODIMP nsAppShellService::Quit() { -#if 0 - // Shutdown all components. - EnumerateComponents( &nsAppShellService::ShutdownComponent ); - mAppShell->Exit(); // this is rude, and gtk complains -#else - nsresult rv; - - // Shutdown all components. - EnumerateComponents(&nsAppShellService::ShutdownComponent); - - // now step through all opened registered windows and close them. + if ( mQuiting ) + return NS_OK; + nsresult rv; + mQuiting = true; + // now step through all opened registered windows and close them. NS_WITH_SERVICE(nsIWindowMediator, windowMediator, kWindowMediatorCID, &rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr windowEnumerator; @@ -487,8 +483,17 @@ nsAppShellService::Shutdown(void) windowEnumerator->HasMoreElements(&more); } } - } -#endif + } + + return mAppShell->Exit(); +} + +NS_IMETHODIMP +nsAppShellService::Shutdown(void) +{ + // Shutdown all components. + EnumerateComponents(&nsAppShellService::ShutdownComponent); + return NS_OK; } @@ -747,7 +752,20 @@ nsAppShellService::UnregisterTopLevelWindow(nsIWebShellWindow* aWindow) rv = mWindowList->Count(&cnt); if (NS_FAILED(rv)) return rv; if (0 == cnt) - mAppShell->Exit(); + { + #if XP_MAC + // Given hidden window the focus so it puts up the menu + nsIWidget* widget = NULL; + mHiddenWindow->GetWidget( widget ); + if( widget ) + { + widget->SetFocus(); + widget->Release(); + } + #else + Quit(); + #endif + } return rv; }