Skip to content

Commit

Permalink
Merge pull request #48 from tyeen/elcapitan_crash
Browse files Browse the repository at this point in the history
Fix recursively calling of menuDidChange:
  • Loading branch information
Aliaksandr Andrashuk committed Jun 9, 2015
2 parents 69295b9 + a202fa7 commit 1cbd247
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 1cbd247

Please sign in to comment.