diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp index 7e47f6a3f53..2789e938240 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportOS2.cpp @@ -1568,8 +1568,16 @@ nsNativeAppSupportOS2::HandleRequest( LPBYTE request, PRBool newWindow ) { rv = appShell->GetNativeAppSupport( getter_AddRefs( native )); if (NS_SUCCEEDED(rv)) { native->SetIsServerMode( PR_FALSE ); - // This closes app if there are no top-level windows. - appShell->UnregisterTopLevelWindow( 0 ); + + // close app if there are no more top-level windows. + PRBool quitIfNoWindows = PR_FALSE; + appShell->GetQuitOnLastWindowClosing( &quitIfNoWindows ); + if (quitIfNoWindows) { + nsCOMPtr win; + GetMostRecentWindow( 0, getter_AddRefs( win ) ); + if (!win) + appShell->Quit(); + } } return; diff --git a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp index e3ec4a665fa..f8f7ae08e45 100644 --- a/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp +++ b/mozilla/xpfe/bootstrap/nsNativeAppSupportWin.cpp @@ -1260,8 +1260,16 @@ nsNativeAppSupportWin::HandleRequest( LPBYTE request, PRBool newWindow ) { rv = appShell->GetNativeAppSupport( getter_AddRefs( native )); if (NS_SUCCEEDED(rv)) { native->SetIsServerMode( PR_FALSE ); - // This closes app if there are no top-level windows. - appShell->UnregisterTopLevelWindow( 0 ); + + // close app if there are no more top-level windows. + PRBool quitIfNoWindows = PR_FALSE; + appShell->GetQuitOnLastWindowClosing( &quitIfNoWindows ); + if (quitIfNoWindows) { + nsCOMPtr win; + GetMostRecentWindow( 0, getter_AddRefs( win ) ); + if (!win) + appShell->Quit(); + } } return;