JUCE
JUCE copied to clipboard
[Bug]: Windows Native FileChooser calls async callback immediately when shown from AlertWindow callback
Detailed steps on how to reproduce the bug
- Set up an alert window with AlertWindow::showAsync(), with some way to launch this alert window in the GUI (like a button)
- Inside the AlertWindow::showAsync callback, create a Windows native FileChooser object (using best practices like a unique_ptr member in parent class) and call FileChooser::launchAsync() with a callback
- Have the FileChooser callback e.g. log something so you can easily see when it's called
- Launch the binary
- Trigger the alert window to show
- Dismiss the alert, so that the FileChooser is created by the alert callback
- Cancel the file chooser by clicking the "Cancel" button
- Repeat steps 5 through 7
The FileChooser will not show up the second time, and the FileChooser callback will be immediately invoked with an empty result, despite the user not doing anything.
Note that this ONLY happens when the FileChooser is launched from the AlertWindow::showAsync() callback. If you launch the FileChooser directly, it will work as expected.
This problem is fully deterministic for me; I can repeat it at will. I've carefully walked through things in the MSVC debugger and all of my code looks good. Sadly for whatever reason I can't step through the native FileChooser code to see why it's immediately calling the callback and not showing the dialog.
What is the expected behaviour?
The FileChooser should show up again as usual, and call its callback only once the user has picked a file or cancelled
Operating systems
Windows
What versions of the operating systems?
Windows 11, up to date patches
Architectures
x86_64
Stacktrace
No response
Plug-in formats (if applicable)
No response
Plug-in host applications (DAWs) (if applicable)
No response
Testing on the develop
branch
The bug is present on the develop
branch
Code of Conduct
- [X] I agree to follow the Code of Conduct
It might be worth mentioning why I'm launching a file chooser from an alert window callback: it's because I'm doing a check to see if the current preset is modified, and am notifying the user so they can choose to cancel loading a new preset (to e.g. save the modified one first).