diff --git a/mozilla/xpfe/appshell/src/nsXULWindow.cpp b/mozilla/xpfe/appshell/src/nsXULWindow.cpp index 99c20974cd5..c8e817d8411 100644 --- a/mozilla/xpfe/appshell/src/nsXULWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsXULWindow.cpp @@ -317,10 +317,19 @@ NS_IMETHODIMP nsXULWindow::Create() NS_IMETHODIMP nsXULWindow::Destroy() { - mBeingDestroyed = PR_TRUE; if(!mWindow) return NS_OK; + { + /* unregister before setting mBeingDestroyed because -turbo code + wants to be able to pose a dialog. */ + nsCOMPtr appShell(do_GetService(kAppShellServiceCID)); + if(appShell) + appShell->UnregisterTopLevelWindow(NS_STATIC_CAST(nsIXULWindow*, this)); + } + + mBeingDestroyed = PR_TRUE; + nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); if (parentWindow) parentWindow->RemoveChildWindow(this); @@ -348,10 +357,6 @@ NS_IMETHODIMP nsXULWindow::Destroy() } #endif - nsCOMPtr appShell(do_GetService(kAppShellServiceCID)); - if(appShell) - appShell->UnregisterTopLevelWindow(NS_STATIC_CAST(nsIXULWindow*, this)); - // let's make sure the window doesn't get deleted out from under us // while we are trying to close....this can happen if the docshell // we close ends up being the last owning reference to this xulwindow