rkeen-siemens opened a new issue, #8667:
URL: https://github.com/apache/netbeans/issues/8667
### 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:
```java
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:
1. Closing the first dialog submits a `WINDOW_CLOSED` event to the event
queue
2. Before the event is processed, `notify` opens the second dialog
3. This end up in `DialogDisplayerImpl.AWTQuery.showDialog()` which
ultimately gets the new dialog’s parent using
`org.openide.util.Utilities.findDialogParent`
4. This returns the active window from
`KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow()` which
is still the now closed first dialog because the `WINDOW_CLOSED` event 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:
```java
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists