Mac: Re-initialize the Native Application Menu on run.

This resolves #1511.
This commit is contained in:
Pale Moon
2017-11-30 21:23:30 +01:00
committed by Roy Tam
parent 53e19a3f7f
commit 0cb3aaf4e0
3 changed files with 11 additions and 0 deletions
+2
View File
@@ -28,6 +28,7 @@
#include "nsCocoaFeatures.h"
#include "nsCocoaUtils.h"
#include "nsChildView.h"
#include "nsMenuBarX.h"
#include "nsToolkit.h"
#include "TextInputHandler.h"
#include "mozilla/HangMonitor.h"
@@ -647,6 +648,7 @@ nsAppShell::Run(void)
mStarted = true;
AddScreenWakeLockListener();
nsMenuBarX::ResetNativeApplicationMenu();
NS_OBJC_TRY_ABORT([NSApp run]);
+1
View File
@@ -127,6 +127,7 @@ public:
void ForceUpdateNativeMenuAt(const nsAString& indexString);
void ForceNativeMenuReload(); // used for testing
static char GetLocalizedAccelKey(const char *shortcutID);
static void ResetNativeApplicationMenu();
protected:
void ConstructNativeMenus();
+8
View File
@@ -498,6 +498,14 @@ char nsMenuBarX::GetLocalizedAccelKey(const char *shortcutID)
return retval;
}
/* static */
void nsMenuBarX::ResetNativeApplicationMenu()
{
[sApplicationMenu removeAllItems];
[sApplicationMenu release];
sApplicationMenu = nil;
}
// Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so
// the caller can hang onto it if they so choose. It is acceptable to pass nsull
// for |outHiddenNode| if the caller doesn't care about the hidden node.