Skip to content

Commit

Permalink
Fix recursively calling of menuDidChange:
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeen committed Jun 9, 2015
1 parent 69295b9 commit a202fa7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Backlight/AAABacklight.m
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,22 @@ - (void)adjustColor:(id)sender

- (void)menuDidChange:(NSNotification *)notification
{
// NOTE: This is just a workaround. We remove and re-add the observer.
// In 10.11 DP, the NSMenuDidChangeItemNotification fires everytime a new menu item is "adding",
// of course including the item we're trying to add now.
// It is supposed to be a system bug because "DidChange" should be notified AFTER the changes.
// Similar bug is reported in Xcode plug-in "FuzzyAutoComplete"'s issue, which is considered as
// a bug introduced by 10.10.2-dp:
// https://github.com/FuzzyAutocomplete/FuzzyAutocompletePlugin/pull/57
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSMenuDidChangeItemNotification
object:nil];
if (![self hasMenuBuilt]) {
[self buildMenus];
}

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuDidChange:)
name:NSMenuDidChangeItemNotification object:nil];
}

- (void)backlightNotification:(NSNotification *)notification
Expand Down

0 comments on commit a202fa7

Please sign in to comment.