Repository navigation
Menus: a check that raises no longer leaves later items stale (#354) - #379
Merged
Merged
Conversation
GNUstep checks a whole menu inside one exception handler (-[NSMenu update]). When one -validateMenuItem: raised, for example when Paste as New Image asked a pasteboard server that didn't answer, the pass stopped there. Every later item kept the state it had before, so Copy Text and Redact Emails and Phone Numbers showed disabled with an image open. -validateMenuItem: now catches the exception, logs the action and the exception, and disables only that item for this pass. The rest of the menu is still checked, and the next pass checks the item again. This is shared code, so it applies on every platform. MenuValidationExceptionProbeTests has three tests: - a check that raises disables its item and doesn't raise; - the item after a raising check is still checked; - GNUstep stops a menu pass at an unguarded raise (GNUstep only). Without the fix, the first two fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AEr1tY2QmxWFSoDkDHs2DC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #354. This is the 0.4.0 fix Dan chose in #8513.
What happened
GNUstep checks a whole menu inside one exception handler (
-[NSMenu update], NSMenu.m:1064–1082 at gui-0_32_0). If one-validateMenuItem:raised, the pass stopped there, and every later item kept whatever state it had before.Source reading points to Paste as New Image's clipboard check as the likely trigger.
-clipboardHasImagegoes through[NSPasteboard generalPasteboard], which is a round trip to GNUstep's pasteboard server. When that server doesn't answer, the call raisesNSPasteboardCommunicationException.The screenshot in #354 fits a pass that stopped at Paste as New Image:
A complete pass can't produce that combination. The trace is in the #354 comments.
The change
-validateMenuItem:now wraps its checks, which move unchanged into-validateMenuItemUnguarded:, in@try/@catch.return YESand has no check that can raise. Only an item whose check failed reaches the@catch.Tests
MenuValidationExceptionProbeTests(new, headless):Results on Windows (MSYS2 CLANG64):
The Mac and Linux suites need re-running on this change, because it's in shared code.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AEr1tY2QmxWFSoDkDHs2DC