With modal juce dialogs, it should be pretty straightforward to find and dismiss them using ModalComponentManager, and then re-trigger the quit message with JUCEApplication::quit().
Oh, I didn’t know about ModalComponentManager, I sort of rolled my own, but “dismissing” the modal dialog (that is, with Component::exitModalState(0) ?) doesn’t seem to bypass the issue, and I believe i know why (see below).
I’m going to redo this with ModalComponentManager - I love deleting my own code but I imagine the results will be quite the same - I’ll still end up in my quit phase with the pointer to a component I know to be modal but be unable to delete it.
Now, the stack is very interesting, and I’m attaching two of them to this post. What it shows is that the call to quit is being done from inside Component::runModalLoop - so no wonder the window isn’t popped down or deleted yet, I’m still in the modal loop that’s reading the buttons!
If you try the same thing with the JUCE demo and a system dialog, you get the same result I do with system dialogs - here we’re hitting a jassert, which will not fire in a release build, but we’re still getting an incorrect result - memory leak checking should be the very last thing to go off, quit should always go off from the top level and all dialogs should be unwound before it happepns.
The Demo doesn’t actually pop up a non-modal dialog but I’d bet 3:2 that it would have the same problem I do if it did.
I think you’re hinting at this, Jules, but clearly there’s some way to suspend the quit process and return control to the modal dialog loop and then have that propagate the quit process back to the top? That’s basically the only solution to this issue.
The logical solution to this whole issue would be to have the Demo put up, say, a juce::KeyMappingEditorComponent in a dialog. This would show off Juce’s marvy KeyMappingEditorComponent and also demonstrate how to correctly create - and destroy during shutdown - a non-system-dialog modal component.
I’m going to be updating to the tip anyway today so will probably see how quickly I can just toss that somewhere into the Demo and put up a patch to see what would happen - and then if I’m doing something wrong, we can correct it and put the right result into the Demo.