Fix a crash related to the hidden window menu bar. Remove obsolete #ifdef XP_MAC. b=358607 r=josh

This commit is contained in:
mats.palmgren%bredband.net 2006-11-16 03:25:55 +00:00
parent 03610c78ba
commit ed37e48bb9
2 changed files with 10 additions and 17 deletions

View File

@ -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<nsIAppShellService> 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<nsIXULWindow> 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();
}

View File

@ -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<nsIPrefBranch> 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<nsIWindowMediator> mediator
( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID) );