mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-03 03:30:06 +00:00
Deallocate all nodes in the graph before calling JUCEApplication::quit in the audio demo host
Some NI plug-ins really don't like it if you call [NSApp stop] while they are still loaded. Fixes #89
This commit is contained in:
parent
8994f37dd0
commit
59cc979cfe
4 changed files with 54 additions and 33 deletions
|
|
@ -105,7 +105,9 @@ MainHostWindow::MainHostWindow()
|
|||
->getIntValue ("pluginSortMethod", KnownPluginList::sortByManufacturer);
|
||||
|
||||
knownPluginList.addChangeListener (this);
|
||||
getGraphEditor()->graph.addChangeListener (this);
|
||||
|
||||
if (FilterGraph* filterGraph = getGraphEditor()->graph.get())
|
||||
filterGraph->addChangeListener (this);
|
||||
|
||||
addKeyListener (getCommandManager().getKeyMappings());
|
||||
|
||||
|
|
@ -131,7 +133,9 @@ MainHostWindow::~MainHostWindow()
|
|||
#endif
|
||||
|
||||
knownPluginList.removeChangeListener (this);
|
||||
getGraphEditor()->graph.removeChangeListener (this);
|
||||
|
||||
if (FilterGraph* filterGraph = getGraphEditor()->graph.get())
|
||||
filterGraph->removeChangeListener (this);
|
||||
|
||||
getAppProperties().getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString());
|
||||
clearContentComponent();
|
||||
|
|
@ -147,8 +151,12 @@ bool MainHostWindow::tryToQuitApplication()
|
|||
PluginWindow::closeAllCurrentlyOpenWindows();
|
||||
|
||||
if (getGraphEditor() == nullptr
|
||||
|| getGraphEditor()->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
|| 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;
|
||||
}
|
||||
|
|
@ -172,11 +180,11 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster* changed)
|
|||
getAppProperties().saveIfNeeded();
|
||||
}
|
||||
}
|
||||
else if (changed == &getGraphEditor()->graph)
|
||||
else if (changed == getGraphEditor()->graph)
|
||||
{
|
||||
String title = JUCEApplication::getInstance()->getApplicationName();
|
||||
|
||||
File f = getGraphEditor()->graph.getFile();
|
||||
File f = getGraphEditor()->graph->getFile();
|
||||
|
||||
if (f.existsAsFile())
|
||||
title = f.getFileName() + " - " + title;
|
||||
|
|
@ -260,7 +268,8 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
|
|||
if (menuItemID == 250)
|
||||
{
|
||||
if (graphEditor != nullptr)
|
||||
graphEditor->graph.clear();
|
||||
if (FilterGraph* filterGraph = getGraphEditor()->graph.get())
|
||||
filterGraph->clear();
|
||||
}
|
||||
else if (menuItemID >= 100 && menuItemID < 200)
|
||||
{
|
||||
|
|
@ -268,8 +277,10 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/
|
|||
recentFiles.restoreFromString (getAppProperties().getUserSettings()
|
||||
->getValue ("recentFilterGraphFiles"));
|
||||
|
||||
if (graphEditor != nullptr && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph.loadFrom (recentFiles.getFile (menuItemID - 100), true);
|
||||
if (graphEditor != nullptr
|
||||
&& getGraphEditor()->graph != nullptr
|
||||
&& graphEditor->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph->loadFrom (recentFiles.getFile (menuItemID - 100), true);
|
||||
}
|
||||
else if (menuItemID >= 200 && menuItemID < 210)
|
||||
{
|
||||
|
|
@ -411,23 +422,23 @@ bool MainHostWindow::perform (const InvocationInfo& info)
|
|||
switch (info.commandID)
|
||||
{
|
||||
case CommandIDs::newFile:
|
||||
if (graphEditor != nullptr && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph.newDocument();
|
||||
if (graphEditor != nullptr && graphEditor->graph != nullptr && graphEditor->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph->newDocument();
|
||||
break;
|
||||
|
||||
case CommandIDs::open:
|
||||
if (graphEditor != nullptr && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph.loadFromUserSpecifiedFile (true);
|
||||
if (graphEditor != nullptr && graphEditor->graph != nullptr && graphEditor->graph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph->loadFromUserSpecifiedFile (true);
|
||||
break;
|
||||
|
||||
case CommandIDs::save:
|
||||
if (graphEditor != nullptr)
|
||||
graphEditor->graph.save (true, true);
|
||||
if (graphEditor != nullptr && graphEditor->graph != nullptr)
|
||||
graphEditor->graph->save (true, true);
|
||||
break;
|
||||
|
||||
case CommandIDs::saveAs:
|
||||
if (graphEditor != nullptr)
|
||||
graphEditor->graph.saveAs (File::nonexistent, true, true, true);
|
||||
if (graphEditor != nullptr && graphEditor->graph != nullptr)
|
||||
graphEditor->graph->saveAs (File::nonexistent, true, true, true);
|
||||
break;
|
||||
|
||||
case CommandIDs::showPluginListEditor:
|
||||
|
|
@ -506,8 +517,8 @@ void MainHostWindow::showAudioSettings()
|
|||
|
||||
GraphDocumentComponent* const graphEditor = getGraphEditor();
|
||||
|
||||
if (graphEditor != nullptr)
|
||||
graphEditor->graph.removeIllegalConnections();
|
||||
if (graphEditor != nullptr && graphEditor->graph != nullptr)
|
||||
graphEditor->graph->removeIllegalConnections();
|
||||
}
|
||||
|
||||
bool MainHostWindow::isInterestedInFileDrag (const StringArray&)
|
||||
|
|
@ -535,8 +546,9 @@ void MainHostWindow::filesDropped (const StringArray& files, int x, int y)
|
|||
{
|
||||
if (files.size() == 1 && File (files[0]).hasFileExtension (filenameSuffix))
|
||||
{
|
||||
if (graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
graphEditor->graph.loadFrom (File (files[0]), true);
|
||||
if (FilterGraph* filterGraph = graphEditor->graph.get())
|
||||
if (filterGraph->saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk)
|
||||
filterGraph->loadFrom (File (files[0]), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue