diff --git a/examples/audio plugin host/Source/MainHostWindow.cpp b/examples/audio plugin host/Source/MainHostWindow.cpp index 508a31a653..37c96af1ed 100644 --- a/examples/audio plugin host/Source/MainHostWindow.cpp +++ b/examples/audio plugin host/Source/MainHostWindow.cpp @@ -149,22 +149,37 @@ void MainHostWindow::closeButtonPressed() tryToQuitApplication(); } -bool MainHostWindow::tryToQuitApplication() +struct AsyncQuitRetrier : private Timer +{ + AsyncQuitRetrier() { startTimer (500); } + + void timerCallback() override + { + stopTimer(); + delete this; + + if (auto app = JUCEApplicationBase::getInstance()) + app->systemRequestedQuit(); + } +}; + +void MainHostWindow::tryToQuitApplication() { PluginWindow::closeAllCurrentlyOpenWindows(); - if (getGraphEditor() == nullptr - || getGraphEditor()->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk) + if (ModalComponentManager::getInstance()->cancelAllModalComponents()) + { + new AsyncQuitRetrier(); + } + else if (getGraphEditor() == nullptr + || getGraphEditor()->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk) { // Some plug-ins do not want [NSApp stop] to be called // before the plug-ins are not deallocated. getGraphEditor()->releaseGraph(); JUCEApplication::quit(); - return true; } - - return false; } void MainHostWindow::changeListenerCallback (ChangeBroadcaster* changed) diff --git a/examples/audio plugin host/Source/MainHostWindow.h b/examples/audio plugin host/Source/MainHostWindow.h index 1e817ddb5e..fd16dc6ab0 100644 --- a/examples/audio plugin host/Source/MainHostWindow.h +++ b/examples/audio plugin host/Source/MainHostWindow.h @@ -81,7 +81,7 @@ public: void getCommandInfo (CommandID commandID, ApplicationCommandInfo& result); bool perform (const InvocationInfo& info); - bool tryToQuitApplication(); + void tryToQuitApplication(); void createPlugin (const PluginDescription&, Point pos);