New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent menu update while it's open #12809

Merged
merged 3 commits into from May 17, 2018

Conversation

Projects
None yet
4 participants
@sethlu
Member

sethlu commented May 3, 2018

Menu change should be prevented while the menu is open

Fixes: #12636

Update application menu on default runloop
Menu change should be prevented while the menu is open

@sethlu sethlu requested a review from electron/reviewers as a code owner May 3, 2018

@@ -20,6 +20,8 @@
namespace api {
static NSMenu* applicationMenu_ = nil;

This comment has been minimized.

@MarshallOfSound

MarshallOfSound May 3, 2018

Member

Why does this have to be static?

This comment has been minimized.

@sethlu

sethlu May 3, 2018

Member

@MarshallOfSound With the static keyword, applicationMenu_ remains visible only to this translation unit when the file is compiled.

This comment has been minimized.

@ckerr

ckerr May 3, 2018

Member

shouldn't it be in an unnamed namespace then? That's what we use in other obj-c files, e.g.:

./atom/browser/ui/drag_util_mac.mm:namespace {
./atom/browser/ui/tray_icon_cocoa.mm:namespace {
./atom/browser/ui/file_dialog_mac.mm:namespace {
./atom/browser/ui/message_box_mac.mm:namespace {
./atom/browser/auto_updater_mac.mm:namespace {
./atom/browser/auto_updater_mac.mm:namespace {
./atom/browser/api/atom_api_browser_window_mac.mm:namespace {
./atom/browser/api/atom_api_system_preferences_mac.mm:namespace {
./atom/browser/mac/atom_application.mm:namespace {
./atom/browser/mac/in_app_purchase_observer.mm:namespace {
./atom/common/platform_util_mac.mm:namespace {
./atom/app/atom_main_delegate_mac.mm:namespace {

This comment has been minimized.

@sethlu

sethlu May 3, 2018

Member

@ckerr 👍 I've updated the code style

clicked the wrong button

@@ -16,6 +16,12 @@
using content::BrowserThread;
namespace {
static NSMenu* applicationMenu_ = nil;

This comment has been minimized.

@MarshallOfSound

MarshallOfSound May 3, 2018

Member

We shouldn't need static here while in the namespace right?

This comment has been minimized.

@sethlu

sethlu May 5, 2018

Member

@MarshallOfSound I'd prefer having the static keyword there so it won't conflict with other applicationMenu_ in other files in the future due to redefinition.

Here are some other usages of this keyword that I've found:

./atom/browser/mac/atom_application_delegate.mm
  22,1: static base::mac::ScopedObjCClassSwizzler* g_swizzle_imk_input_session;

./atom/browser/api/atom_api_power_monitor_mac.mm
  64,1: static MacLockMonitor* g_lock_monitor = nil;

./atom/browser/ui/cocoa/atom_touch_bar.mm
  15,1: static NSTouchBarItemIdentifier ButtonIdentifier =
  17,1: static NSTouchBarItemIdentifier ColorPickerIdentifier =
  19,1: static NSTouchBarItemIdentifier GroupIdentifier =
  21,1: static NSTouchBarItemIdentifier LabelIdentifier =
  23,1: static NSTouchBarItemIdentifier PopoverIdentifier =
  25,1: static NSTouchBarItemIdentifier SliderIdentifier =
  27,1: static NSTouchBarItemIdentifier SegmentedControlIdentifier =
  29,1: static NSTouchBarItemIdentifier ScrubberIdentifier =
  32,1: static NSString* const TextScrubberItemIdentifier = @"scrubber.text.item";
  33,1: static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";

./atom/browser/ui/cocoa/atom_menu_controller.mm
  62,1: static base::scoped_nsobject<NSMenuItem> recentDocumentsMenuItem_;
  65,1: static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
@ckerr

This comment has been minimized.

Member

ckerr commented May 3, 2018

This CI failure looks like a flake to me. Re-starting the job

@ckerr

ckerr approved these changes May 3, 2018

@codebytere

This comment has been minimized.

Member

codebytere commented May 16, 2018

Is this ready to go? Seems ready to me

@MarshallOfSound MarshallOfSound merged commit d2653e8 into electron:master May 17, 2018

10 checks passed

WIP ready for review
Details
ci/circleci: electron-linux-arm Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-arm64-test Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-ia32 Your tests passed on CircleCI!
Details
ci/circleci: electron-linux-x64 Your tests passed on CircleCI!
Details
ci/circleci: electron-mas-x64 Your tests passed on CircleCI!
Details
ci/circleci: electron-osx-x64 Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@codebytere

This comment has been minimized.

Member

codebytere commented Aug 5, 2018

/trop run backport-to 2-0-x

@trop

This comment has been minimized.

Contributor

trop bot commented Aug 5, 2018

The backport process for this PR has been manually initiated, sending your 1's and 0's to "2-0-x" here we go! :D

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Aug 6, 2018

/trop run backport-to 2-0-x

@trop

This comment has been minimized.

Contributor

trop bot commented Aug 6, 2018

The backport process for this PR has been manually initiated, sending your 1's and 0's to "2-0-x" here we go! :D

@trop

This comment has been minimized.

Contributor

trop bot commented Aug 6, 2018

An error occurred while attempting to backport this PR to "2-0-x", you will need to perform this backport manually

@MarshallOfSound

This comment has been minimized.

Member

MarshallOfSound commented Aug 6, 2018

Instruction: SET_UP_REMOTES
Instruction: BACKPORT
error: patch failed: atom/browser/api/atom_api_menu_mac.mm:20
error: atom/browser/api/atom_api_menu_mac.mm: patch does not apply

Error: error: patch failed: atom/browser/api/atom_api_menu_mac.mm:20
error: atom/browser/api/atom_api_menu_mac.mm: patch does not apply

Yeah, don't know what happened with the first trop, second one errored out legitimately 👍

@ckerr

This comment has been minimized.

Member

ckerr commented Aug 7, 2018

@sethlu, @MarshallOfSound, @codebytere: does this also need to be fixed in 3-0-x?

@sethlu

This comment has been minimized.

Member

sethlu commented Aug 7, 2018

@ckerr I don't think we need to. It's merged before we cut for 3-0-x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment