Bug 1181977 - Firefox app menu contains only "Quit" in certain edgecases. r=spohl

This commit is contained in:
Steven Michaud 2015-08-24 10:57:02 -05:00
Родитель bb40e2959b
Коммит d59e2ac8dc
2 изменённых файлов: 8 добавлений и 2 удалений

Просмотреть файл

@ -28,7 +28,6 @@
#include "nsCocoaFeatures.h"
#include "nsCocoaUtils.h"
#include "nsChildView.h"
#include "nsMenuBarX.h"
#include "nsToolkit.h"
#include "TextInputHandler.h"
#include "mozilla/HangMonitor.h"
@ -658,7 +657,6 @@ nsAppShell::Run(void)
mStarted = true;
AddScreenWakeLockListener();
nsMenuBarX::ResetNativeApplicationMenu();
NS_OBJC_TRY_ABORT([NSApp run]);

Просмотреть файл

@ -33,6 +33,7 @@ NativeMenuItemTarget* nsMenuBarX::sNativeEventTarget = nil;
nsMenuBarX* nsMenuBarX::sLastGeckoMenuBarPainted = nullptr; // Weak
nsMenuBarX* nsMenuBarX::sCurrentPaintDelayedMenuBar = nullptr; // Weak
NSMenu* sApplicationMenu = nil;
BOOL sApplicationMenuIsFallback = NO;
BOOL gSomeMenuBarPainted = NO;
// We keep references to the first quit and pref item content nodes we find, which
@ -186,6 +187,7 @@ void nsMenuBarX::ConstructFallbackNativeMenus()
[quitMenuItem setTarget:nsMenuBarX::sNativeEventTarget];
[quitMenuItem setTag:eCommand_ID_Quit];
[sApplicationMenu addItem:quitMenuItem];
sApplicationMenuIsFallback = YES;
}
uint32_t nsMenuBarX::GetMenuCount()
@ -207,6 +209,11 @@ nsresult nsMenuBarX::InsertMenuAtIndex(nsMenuX* aMenu, uint32_t aIndex)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
// If we've only yet created a fallback global Application menu (using
// ContructFallbackNativeMenus()), destroy it before recreating it properly.
if (sApplicationMenu && sApplicationMenuIsFallback) {
ResetNativeApplicationMenu();
}
// If we haven't created a global Application menu yet, do it.
if (!sApplicationMenu) {
nsresult rv = NS_OK; // avoid warning about rv being unused
@ -506,6 +513,7 @@ void nsMenuBarX::ResetNativeApplicationMenu()
[sApplicationMenu removeAllItems];
[sApplicationMenu release];
sApplicationMenu = nil;
sApplicationMenuIsFallback = NO;
}
// Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so