Browse Source

Added a better shutdown procedure for the plugin host demo

tags/2021-05-28
jules 8 years ago
parent
commit
38ba6e9884
2 changed files with 22 additions and 7 deletions
  1. +21
    -6
      examples/audio plugin host/Source/MainHostWindow.cpp
  2. +1
    -1
      examples/audio plugin host/Source/MainHostWindow.h

+ 21
- 6
examples/audio plugin host/Source/MainHostWindow.cpp View File

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


+ 1
- 1
examples/audio plugin host/Source/MainHostWindow.h View File

@@ -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<int> pos);


Loading…
Cancel
Save