8389735: [macos] Closing owner of FileChooser breaks other windows - #2242
Open
FlorianKirmaier wants to merge 1 commit into
Open
Conversation
|
👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into |
FlorianKirmaier
force-pushed
the
JDK-8389735_macos-closing-owner-of-filechooser-breaks-windows
branch
from
August 4, 2026 21:53
86dda4a to
5e36bb5
Compare
|
❗ This change is not yet ready to be integrated. |
|
@FlorianKirmaier Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
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.
Description
The setup is the following:
Window1
Window2 owner Window1
FileChooser owner Window2
When Window2 is closed,
then Window2 and the FileChooser are closed,
but the nested event loop from the dialog never returns.
Even worse, Window1 is in a broken state: it can't ever get focus again.
The Fix
The fix has two parts.
Close FileChooser when owner is closed (GlassDialogs.m)
AppKit does not call the completionHandler of the dialog when the owner window is closed, so the nested event loop is never left.
We add a listener to the owner of the FileChooser, ensuring the FileChooser gets closed when the owner is closed.
showOpenDialog then returns null, as if the user had cancelled.
Refocus when disabled window becomes key/focused (GlassWindow.m)
When a window becomes focused while it is disabled, the focus isn't processed.
Therefore we resend the focus event when it gets re-enabled.
System test
A system test is included which tests both changes at once.
A note on platform differences
On Windows/Linux, closing the owner of a FileChooser currently doesn't close
the FileChooser at all. For that reason, the test only works on macOS.
But this difference is not introduced by the PR.
It probably would be possible to change that behavior and it would be a good
additional improvement, because in all other cases, closing the owner also closes the child windows.
From the Stage JavaDoc (class doc, showAndWait doc):
Close API
A possible follow-up would be to provide an API to close the FileChooser programmatically.
This would also make it easier to write tests.
Progress
Error
- [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2242/head:pull/2242$ git checkout pull/2242Update a local copy of the PR:
$ git checkout pull/2242$ git pull https://git.openjdk.org/jfx.git pull/2242/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2242View PR using the GUI difftool:
$ git pr show -t 2242Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2242.diff