JUCE icon indicating copy to clipboard operation
JUCE copied to clipboard

[Bug]: Windows Native FileChooser calls async callback immediately when shown from AlertWindow callback

Open emezeske opened this issue 1 year ago • 1 comments

Detailed steps on how to reproduce the bug

  1. Set up an alert window with AlertWindow::showAsync(), with some way to launch this alert window in the GUI (like a button)
  2. 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
  3. Have the FileChooser callback e.g. log something so you can easily see when it's called
  4. Launch the binary
  5. Trigger the alert window to show
  6. Dismiss the alert, so that the FileChooser is created by the alert callback
  7. Cancel the file chooser by clicking the "Cancel" button
  8. 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

emezeske avatar Oct 13 '23 21:10 emezeske

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

emezeske avatar Oct 13 '23 21:10 emezeske