-
Notifications
You must be signed in to change notification settings - Fork 914
Open
Labels
Contribution welcomeAn issue or feature not currently being worked on, but a contribution would be welcomed!An issue or feature not currently being worked on, but a contribution would be welcomed!Platform[ci] enable platform tests (platform/*)[ci] enable platform tests (platform/*)kind:bugBug report or fixBug report or fixneeds:triageRequires attention from one of the committersRequires attention from one of the committers
Description
Apache NetBeans version
Apache NetBeans 26
What happened
Utilities.findDialogParent can return a non-visible component which is effectively equivalent to null and will cause issues similar to #4739 and #5987.
Language / Project Type / NetBeans Component
No response
How to reproduce
Run the following code on the EDT:
DialogDescriptor first = new DialogDescriptor("Parent is the main window", "First");
DialogDisplayer.getDefault().notify(first);
DialogDescriptor second = new DialogDescriptor("Parent is first's dialog", "Second");
DialogDisplayer.getDefault().notify(second);The first dialog will have the main window as the parent, but the second will have the dialog created for first even though it has been closed.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Linux
JDK
21.0.5
Apache NetBeans packaging
Apache NetBeans platform
Anything else
Here's what seems to be happening:
- Closing the first dialog submits a
WINDOW_CLOSEDevent to the event queue - Before the event is processed,
notifyopens the second dialog - This end up in
DialogDisplayerImpl.AWTQuery.showDialog()which ultimately gets the new dialog’s parent usingorg.openide.util.Utilities.findDialogParent - This returns the active window from
KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow()which is still the now closed first dialog because theWINDOW_CLOSEDevent hasn’t yet been processed
Updating Utilities.findDialogParent to resolve a suggested parent via the closed window's owner would probably resolve the issue. Something like this after the modal check may work:
if (parent instanceof Window w) {
while (!w.isVisible()) {
w = w.getOwner();
if (w == null) {
break;
}
}
parent = w;
}Are you willing to submit a pull request?
No
Metadata
Metadata
Assignees
Labels
Contribution welcomeAn issue or feature not currently being worked on, but a contribution would be welcomed!An issue or feature not currently being worked on, but a contribution would be welcomed!Platform[ci] enable platform tests (platform/*)[ci] enable platform tests (platform/*)kind:bugBug report or fixBug report or fixneeds:triageRequires attention from one of the committersRequires attention from one of the committers