Skip to content

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

Merged
MarshallOfSound merged 3 commits into
electron:masterfrom
sethlu:fix-12636
May 17, 2018
Merged

MarshallOfSound merged 3 commits into
electron:masterfrom
sethlu:fix-12636

Conversation

@sethlu

@sethlu sethlu commented May 3, 2018

Copy link
Copy Markdown
Contributor

Menu change should be prevented while the menu is open

Fixes: #12636

Menu change should be prevented while the menu is open
@sethlu
sethlu requested a review from a team May 3, 2018 04:31
MarshallOfSound
MarshallOfSound previously approved these changes May 3, 2018
Comment thread atom/browser/api/atom_api_menu_mac.mm Outdated

namespace api {

static NSMenu* applicationMenu_ = nil;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to be static?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ckerr 👍 I've updated the code style

@MarshallOfSound
MarshallOfSound dismissed their stale review May 3, 2018 05:26

clicked the wrong button

Comment thread atom/browser/api/atom_api_menu_mac.mm Outdated

namespace {

static NSMenu* applicationMenu_ = nil;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

ckerr commented May 3, 2018

Copy link
Copy Markdown
Member

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

@codebytere

Copy link
Copy Markdown
Member

Is this ready to go? Seems ready to me

@codebytere

Copy link
Copy Markdown
Member

/trop run backport-to 2-0-x

@trop

trop Bot commented Aug 5, 2018

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

/trop run backport-to 2-0-x

@trop

trop Bot commented Aug 6, 2018

Copy link
Copy Markdown
Contributor

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

trop Bot commented Aug 6, 2018

Copy link
Copy Markdown
Contributor

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

@MarshallOfSound

Copy link
Copy Markdown
Member
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

ckerr commented Aug 7, 2018

Copy link
Copy Markdown
Member

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

@sethlu

sethlu commented Aug 7, 2018

Copy link
Copy Markdown
Contributor Author

@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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Main app menu is buggy on macOS if user interacts with it while it's being updated

4 participants