Bug 449308: Quitting doesn't work when onbeforeunload handler poses dialog. r=mossop, r+sr=bsmedberg

This commit is contained in:
Honza Bambas 2008-11-04 11:44:23 -08:00
Родитель 7a6c268718
Коммит 4e6fbe70b8
2 изменённых файлов: 27 добавлений и 1 удалений

Просмотреть файл

@ -161,6 +161,16 @@ nsAppStartup::DestroyHiddenWindow()
return appShellService->DestroyHiddenWindow();
}
PRInt32
nsAppStartup::RealQuitStoppers()
{
#ifdef XP_MACOSX
// When attempting quit is set we must subtract the hidden window
return mConsiderQuitStopper - (mAttemptingQuit ? 0 : 1);
#else
return mConsiderQuitStopper;
#endif
}
NS_IMETHODIMP
nsAppStartup::Run(void)
@ -368,8 +378,23 @@ nsAppStartup::CloseAllWindows()
nsCOMPtr<nsIDOMWindowInternal> window = do_QueryInterface(isupports);
NS_ASSERTION(window, "not an nsIDOMWindowInternal");
if (window)
if (window) {
#ifdef XP_MACOSX
PRInt32 quitStoppers = RealQuitStoppers();
#endif
window->Close();
#ifdef XP_MACOSX
if (!mAttemptingQuit) {
PRInt32 currentQuitStoppers = RealQuitStoppers();
// If the current number of windows is smaller or same then the number
// recorded before window close, we must re-attempt quit.
// 'Or same' condition is here because the actual window deregisters
// later asynchronously.
if (currentQuitStoppers <= quitStoppers)
AttemptingQuit(PR_TRUE);
}
#endif
}
}
}

Просмотреть файл

@ -75,6 +75,7 @@ private:
void AttemptingQuit(PRBool aAttempt);
void CloseAllWindows();
inline PRInt32 RealQuitStoppers();
friend class nsAppExitEvent;