Skip to content
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 an infinite loop in OS X 10.10.2 (14C94b) #57

Merged
merged 3 commits into from
Jan 8, 2015

Conversation

luosheng
Copy link
Contributor

@luosheng luosheng commented Jan 8, 2015

It seems adding a menu item will fire the NSMenuDidChangeItemNotification in 10.10.2 (14C94b), which will result in an infinite loop. Remove the observer before adding the item should be good to fix this.

@jxdwinter
Copy link

+1

@slazyk
Copy link
Member

slazyk commented Jan 8, 2015

This does not seem to be a correct fix.

We observe this notification because Editor menu changes (for example when you switch from an .m file to a .xib file). If you just remove the observer, then the menu item will be missing after subsequent changes.

It is weird that it recurs, there is a check not to add the item if it is already there. And since it is DidChange the item should already be there. You could try looking into this for a correct fix.

And for a more correct workaround you can either:

  • introduce a boolean guard flag (something like isHandlingMenuChange) and use it to prevent recurrence
  • inspect the notification and decide wether to try to add the menu item based on it
  • remove and re-add observer as needed (best to do it in the menuDidChange: notification handler though).

@luosheng
Copy link
Contributor Author

luosheng commented Jan 8, 2015

Thanks for the explanation. I've re-added the observer after FuzzyAutocomplete menu item is added to the Editor menu. Please kindly check it out.

slazyk added a commit that referenced this pull request Jan 8, 2015
Workaround for an infinite loop in OS X 10.10.2 (14C94b)
@slazyk slazyk merged commit 197b605 into FuzzyAutocomplete:master Jan 8, 2015
@luosheng luosheng deleted the fix-infinite-loop branch January 8, 2015 17:39
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.

3 participants