diff --git a/widget/src/cocoa/nsCocoaWindow.mm b/widget/src/cocoa/nsCocoaWindow.mm index 7018739870a4..7a5959f0d147 100644 --- a/widget/src/cocoa/nsCocoaWindow.mm +++ b/widget/src/cocoa/nsCocoaWindow.mm @@ -65,9 +65,6 @@ extern BOOL gSomeMenuBarPainted; #define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1" -// call getHiddenWindowNativeMenu, don't use this directly -static nsIMenuBar* gHiddenWindowMenuBar; - NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa) @@ -157,9 +154,6 @@ nsCocoaWindow::~nsCocoaWindow() static nsIMenuBar* GetHiddenWindowMenuBar() { - if (gHiddenWindowMenuBar) - return gHiddenWindowMenuBar; - nsCOMPtr appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); if (!appShell) { NS_WARNING("Couldn't get AppShellService in order to get hidden window ref"); @@ -169,7 +163,7 @@ static nsIMenuBar* GetHiddenWindowMenuBar() nsCOMPtr hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); if (!hiddenWindow) { - NS_WARNING("Couldn't get hidden window from appshell"); + // Don't warn, this happens during shutdown, bug 358607. return nsnull; } @@ -187,13 +181,7 @@ static nsIMenuBar* GetHiddenWindowMenuBar() } nsIWidget* hiddenWindowWidgetNoCOMPtr = hiddenWindowWidget; - nsIMenuBar* geckoMenuBar = NS_STATIC_CAST(nsCocoaWindow*, hiddenWindowWidgetNoCOMPtr)->GetMenuBar(); - - if (geckoMenuBar) { - gHiddenWindowMenuBar = geckoMenuBar; - } - - return gHiddenWindowMenuBar; + return NS_STATIC_CAST(nsCocoaWindow*, hiddenWindowWidgetNoCOMPtr)->GetMenuBar(); } diff --git a/xpfe/appshell/src/nsAppShellService.cpp b/xpfe/appshell/src/nsAppShellService.cpp index 6f4137d8cce5..0463d2408b29 100644 --- a/xpfe/appshell/src/nsAppShellService.cpp +++ b/xpfe/appshell/src/nsAppShellService.cpp @@ -151,7 +151,7 @@ nsAppShellService::CreateHiddenWindow(nsIAppShell* aAppShell) nsresult rv; PRInt32 initialHeight = 100, initialWidth = 100; -#if defined(XP_MAC) || defined(XP_MACOSX) +#ifdef XP_MACOSX static const char defaultHiddenWindowURL[] = "chrome://global/content/hiddenWindow.xul"; PRUint32 chromeMask = 0; nsCOMPtr prefBranch; @@ -177,7 +177,7 @@ nsAppShellService::CreateHiddenWindow(nsIAppShell* aAppShell) mHiddenWindow.swap(newWindow); -#if defined(XP_MAC) || defined(XP_MACOSX) +#ifdef XP_MACOSX // hide the hidden window by launching it into outer space. This // way, we can keep it visible and let the OS send it activates // to keep menus happy. This will cause it to show up in window @@ -253,7 +253,7 @@ nsAppShellService::CalculateWindowZLevel(nsIXULWindow *aParent, else if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_LOWERED) zLevel = nsIXULWindow::loweredZ; -#if defined(XP_MAC) || defined(XP_MACOSX) +#ifdef XP_MACOSX /* Platforms on which modal windows are always application-modal, not window-modal (that's just the Mac, right?) want modal windows to be stacked on top of everyone else. @@ -502,6 +502,11 @@ nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow) NS_ENSURE_ARG_POINTER(aWindow); + if (aWindow == mHiddenWindow) { + // CreateHiddenWindow() does not register the window, so we're done. + return NS_OK; + } + // tell the window mediator nsCOMPtr mediator ( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );