Skip to content

8389735: [macos] Closing owner of FileChooser breaks other windows - #2242

Open
FlorianKirmaier wants to merge 1 commit into
openjdk:masterfrom
FlorianKirmaier:JDK-8389735_macos-closing-owner-of-filechooser-breaks-windows
Open

8389735: [macos] Closing owner of FileChooser breaks other windows#2242
FlorianKirmaier wants to merge 1 commit into
openjdk:masterfrom
FlorianKirmaier:JDK-8389735_macos-closing-owner-of-filechooser-breaks-windows

Conversation

@FlorianKirmaier

@FlorianKirmaier FlorianKirmaier commented Aug 4, 2026

Copy link
Copy Markdown
Member

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):

When a parent window is closed or iconified, then all owned windows will be affected as well
A Stage is hidden (closed) by one of the following means: ... this stage has a non-null owner window, and its owner is closed

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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Error

 ⚠️ Pull request body is missing required line: - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).

Issue

  • JDK-8389735: [macos] Closing owner of FileChooser breaks other windows (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2242/head:pull/2242
$ git checkout pull/2242

Update a local copy of the PR:
$ git checkout pull/2242
$ git pull https://git.openjdk.org/jfx.git pull/2242/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2242

View PR using the GUI difftool:
$ git pr show -t 2242

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2242.diff

@bridgekeeper

bridgekeeper Bot commented Aug 4, 2026

Copy link
Copy Markdown

👋 Welcome back fkirmaier! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

Closing owner of filechooser breaks the state of other windows.
@FlorianKirmaier
FlorianKirmaier force-pushed the JDK-8389735_macos-closing-owner-of-filechooser-breaks-windows branch from 86dda4a to 5e36bb5 Compare August 4, 2026 21:53
@openjdk

openjdk Bot commented Aug 4, 2026

Copy link
Copy Markdown

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot changed the title 8389735 [macos] Closing owner of FileChooser breaks other windows 8389735: [macos] Closing owner of FileChooser breaks other windows Aug 4, 2026
@openjdk

openjdk Bot commented Aug 4, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant