Repository navigation
[GTK4] Destroy a popover disposed during a focus change after it - #3759
Merged
akurtakov merged 1 commit intoOct 23, 2026
Merged
Conversation
GTK sends the focus leave events walking up the widget tree from the old focus widget. A popup disposed by a FocusOut listener was popped down and unparented in the middle of that walk, and GTK looped forever on the destroyed widgets. Queue a popover disposed while a focus callback runs and destroy it after the focus change, from an asyncExec that waits while a listener still runs a nested event loop. Assisted-by: Anthropic Claude Code (claude-opus-5-5)
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
What changed in this PR
Fixes a GTK4 focus-change edge case where disposing a popover during FocusOut can cause GTK to loop on destroyed widgets, by deferring popover teardown until after focus dispatch completes.
Changes:
- Add a regression test that disposes an ON_TOP child shell during
FocusOut. - Defer
gtk_popover_popdown()/gtk_widget_unparent()for popovers disposed inside focus dispatch, and perform the destruction later viaasyncExec. - Track focus-dispatch depth and queue popover handles for deferred destruction.
| File | Description |
|---|---|
| tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java | Adds a regression test that disposes a popup on FocusOut and waits for disposal completion. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | Defers popover popdown/unparent when a shell is released during focus dispatch. |
| bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | Adds focus-dispatch depth tracking and deferred popover destruction via asyncExec. |
Review effort: Lite
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.


GTK sends the focus leave events walking up the widget tree from the old focus widget. A popup disposed by a FocusOut listener was popped down and unparented in the middle of that walk, and GTK looped forever on the destroyed widgets.
Queue a popover disposed while a focus callback runs and destroy it after the focus change, from an asyncExec that waits while a listener still runs a nested event loop.
Assisted-by: Anthropic Claude Code (claude-opus-5-5)