From 3c79dd8967a8eb3247fa3bf912a75c92ad340809 Mon Sep 17 00:00:00 2001 From: "danm-moz%comcast.net" Date: Thu, 19 Feb 2004 23:03:13 +0000 Subject: [PATCH] quit() now returns no error under normal circumstances. bug 185360 r=jag,neil git-svn-id: svn://10.0.0.236/trunk@152982 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xpfe/appshell/src/nsAppShellService.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/mozilla/xpfe/appshell/src/nsAppShellService.cpp b/mozilla/xpfe/appshell/src/nsAppShellService.cpp index 0b49f4126ef..e4544b2a3fc 100644 --- a/mozilla/xpfe/appshell/src/nsAppShellService.cpp +++ b/mozilla/xpfe/appshell/src/nsAppShellService.cpp @@ -499,8 +499,10 @@ nsAppShellService::Quit(PRUint32 aFerocity) /* eForceQuit doesn't actually work; it can cause a subtle crash if there are windows open which have unload handlers which open new windows. Use eAttemptQuit for now. */ - if (aFerocity == eForceQuit) - return NS_ERROR_FAILURE; + if (aFerocity == eForceQuit) { + NS_WARNING("attempted to force quit"); + // it will be treated the same as eAttemptQuit, below + } mShuttingDown = PR_TRUE; @@ -583,9 +585,21 @@ nsAppShellService::Quit(PRUint32 aFerocity) mWindowMediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)); if (windowEnumerator) { PRBool more; - if (NS_SUCCEEDED(windowEnumerator->HasMoreElements(&more)) && more) { + while (windowEnumerator->HasMoreElements(&more), more) { + /* we can't quit immediately. we'll try again as the last window + finally closes. */ aFerocity = eAttemptQuit; - rv = NS_ERROR_FAILURE; + nsCOMPtr window; + windowEnumerator->GetNext(getter_AddRefs(window)); + nsCOMPtr domWindow(do_QueryInterface(window)); + if (domWindow) { + PRBool closed = PR_FALSE; + domWindow->GetClosed(&closed); + if (!closed) { + rv = NS_ERROR_FAILURE; + break; + } + } } } }