From 2100e68adcf03df82826d4ea62c3db2485882f74 Mon Sep 17 00:00:00 2001 From: Julian Storer Date: Sat, 9 Jul 2011 13:18:55 +0100 Subject: [PATCH] Fixed VST hosting compile error. Stopped the ApplicationProperties class being a singleton - instead, just create and use an instance of it in your apps. --- .../audio plugin host/Source/FilterGraph.cpp | 7 ++-- .../audio plugin host/Source/HostStartup.cpp | 13 +++--- .../Source/MainHostWindow.cpp | 42 ++++++++----------- .../audio plugin host/Source/MainHostWindow.h | 2 +- juce_amalgamated.cpp | 15 ++++--- juce_amalgamated.h | 20 ++++----- .../juce_ApplicationProperties.cpp | 5 --- src/application/juce_ApplicationProperties.h | 16 +++---- .../juce_AudioFormatManager.h | 6 +-- .../juce_StandaloneFilterWindow.cpp | 13 ------ .../Standalone/juce_StandaloneFilterWindow.h | 8 ++-- .../formats/juce_VSTPluginFormat.cpp | 14 ++++--- src/core/juce_StandardHeader.h | 2 +- src/text/juce_LocalisedStrings.h | 1 - 14 files changed, 64 insertions(+), 100 deletions(-) diff --git a/extras/audio plugin host/Source/FilterGraph.cpp b/extras/audio plugin host/Source/FilterGraph.cpp index 54c0c80a3e..fbf41ab15c 100644 --- a/extras/audio plugin host/Source/FilterGraph.cpp +++ b/extras/audio plugin host/Source/FilterGraph.cpp @@ -24,6 +24,7 @@ */ #include "../JuceLibraryCode/JuceHeader.h" +#include "MainHostWindow.h" #include "FilterGraph.h" #include "InternalFilters.h" #include "GraphEditorPanel.h" @@ -265,7 +266,7 @@ const String FilterGraph::saveDocument (const File& file) const File FilterGraph::getLastDocumentOpened() { RecentlyOpenedFilesList recentFiles; - recentFiles.restoreFromString (ApplicationProperties::getInstance()->getUserSettings() + recentFiles.restoreFromString (appProperties->getUserSettings() ->getValue ("recentFilterGraphFiles")); return recentFiles.getFile (0); @@ -274,12 +275,12 @@ const File FilterGraph::getLastDocumentOpened() void FilterGraph::setLastDocumentOpened (const File& file) { RecentlyOpenedFilesList recentFiles; - recentFiles.restoreFromString (ApplicationProperties::getInstance()->getUserSettings() + recentFiles.restoreFromString (appProperties->getUserSettings() ->getValue ("recentFilterGraphFiles")); recentFiles.addFile (file); - ApplicationProperties::getInstance()->getUserSettings() + appProperties->getUserSettings() ->setValue ("recentFilterGraphFiles", recentFiles.toString()); } diff --git a/extras/audio plugin host/Source/HostStartup.cpp b/extras/audio plugin host/Source/HostStartup.cpp index b85777384f..b52700574c 100644 --- a/extras/audio plugin host/Source/HostStartup.cpp +++ b/extras/audio plugin host/Source/HostStartup.cpp @@ -32,7 +32,8 @@ #endif -ApplicationCommandManager* commandManager = 0; +ApplicationCommandManager* commandManager = nullptr; +ApplicationProperties* appProperties = nullptr; //============================================================================== @@ -44,10 +45,6 @@ public: { } - ~PluginHostApp() - { - } - void initialise (const String& commandLine) { // initialise our settings file.. @@ -57,7 +54,8 @@ public: options.filenameSuffix = "settings"; options.osxLibrarySubFolder = "Preferences"; - ApplicationProperties::getInstance()->setStorageParameters (options); + appProperties = new ApplicationProperties(); + appProperties->setStorageParameters (options); commandManager = new ApplicationCommandManager(); @@ -85,9 +83,10 @@ public: void shutdown() { mainWindow = 0; - ApplicationProperties::getInstance()->closeFiles(); + appProperties->closeFiles(); deleteAndZero (commandManager); + deleteAndZero (appProperties); } void systemRequestedQuit() diff --git a/extras/audio plugin host/Source/MainHostWindow.cpp b/extras/audio plugin host/Source/MainHostWindow.cpp index 55d59726d1..7844dc4267 100644 --- a/extras/audio plugin host/Source/MainHostWindow.cpp +++ b/extras/audio plugin host/Source/MainHostWindow.cpp @@ -38,24 +38,24 @@ public: { currentPluginListWindow = this; - const File deadMansPedalFile (ApplicationProperties::getInstance()->getUserSettings() + const File deadMansPedalFile (appProperties->getUserSettings() ->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); setContentOwned (new PluginListComponent (knownPluginList, deadMansPedalFile, - ApplicationProperties::getInstance()->getUserSettings()), true); + appProperties->getUserSettings()), true); setResizable (true, false); setResizeLimits (300, 400, 800, 1500); setTopLeftPosition (60, 60); - restoreWindowStateFromString (ApplicationProperties::getInstance()->getUserSettings()->getValue ("listWindowPos")); + restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("listWindowPos")); setVisible (true); } ~PluginListWindow() { - ApplicationProperties::getInstance()->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); + appProperties->getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); clearContentComponent(); @@ -79,7 +79,7 @@ MainHostWindow::MainHostWindow() : DocumentWindow (JUCEApplication::getInstance()->getApplicationName(), Colours::lightgrey, DocumentWindow::allButtons) { - XmlElement* const savedAudioState = ApplicationProperties::getInstance()->getUserSettings() + XmlElement* const savedAudioState = appProperties->getUserSettings() ->getXmlValue ("audioDeviceState"); deviceManager.initialise (256, 256, savedAudioState, true); @@ -92,24 +92,19 @@ MainHostWindow::MainHostWindow() setContentOwned (new GraphDocumentComponent (&deviceManager), false); - restoreWindowStateFromString (ApplicationProperties::getInstance()->getUserSettings()->getValue ("mainWindowPos")); + restoreWindowStateFromString (appProperties->getUserSettings()->getValue ("mainWindowPos")); setVisible (true); InternalPluginFormat internalFormat; internalFormat.getAllTypes (internalTypes); - XmlElement* const savedPluginList = ApplicationProperties::getInstance() - ->getUserSettings() - ->getXmlValue ("pluginList"); + ScopedPointer savedPluginList (appProperties->getUserSettings()->getXmlValue ("pluginList")); - if (savedPluginList != 0) - { + if (savedPluginList != nullptr) knownPluginList.recreateFromXml (*savedPluginList); - delete savedPluginList; - } - pluginSortMethod = (KnownPluginList::SortMethod) ApplicationProperties::getInstance()->getUserSettings() + pluginSortMethod = (KnownPluginList::SortMethod) appProperties->getUserSettings() ->getIntValue ("pluginSortMethod", KnownPluginList::sortByManufacturer); knownPluginList.addChangeListener (this); @@ -137,7 +132,7 @@ MainHostWindow::~MainHostWindow() knownPluginList.removeChangeListener (this); - ApplicationProperties::getInstance()->getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString()); + appProperties->getUserSettings()->setValue ("mainWindowPos", getWindowStateAsString()); clearContentComponent(); } @@ -168,12 +163,11 @@ void MainHostWindow::changeListenerCallback (ChangeBroadcaster*) if (savedPluginList != 0) { - ApplicationProperties::getInstance()->getUserSettings() - ->setValue ("pluginList", savedPluginList); + appProperties->getUserSettings()->setValue ("pluginList", savedPluginList); delete savedPluginList; - ApplicationProperties::getInstance()->saveIfNeeded(); + appProperties->saveIfNeeded(); } } @@ -194,7 +188,7 @@ const PopupMenu MainHostWindow::getMenuForIndex (int topLevelMenuIndex, const St menu.addCommandItem (commandManager, CommandIDs::open); RecentlyOpenedFilesList recentFiles; - recentFiles.restoreFromString (ApplicationProperties::getInstance()->getUserSettings() + recentFiles.restoreFromString (appProperties->getUserSettings() ->getValue ("recentFilterGraphFiles")); PopupMenu recentFilesMenu; @@ -252,7 +246,7 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/ else if (menuItemID >= 100 && menuItemID < 200) { RecentlyOpenedFilesList recentFiles; - recentFiles.restoreFromString (ApplicationProperties::getInstance()->getUserSettings() + recentFiles.restoreFromString (appProperties->getUserSettings() ->getValue ("recentFilterGraphFiles")); if (graphEditor != 0 && graphEditor->graph.saveIfNeededAndUserAgrees() == FileBasedDocument::savedOk) @@ -271,8 +265,7 @@ void MainHostWindow::menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/ else if (menuItemID == 204) pluginSortMethod = KnownPluginList::sortByFileSystemLocation; - ApplicationProperties::getInstance()->getUserSettings() - ->setValue ("pluginSortMethod", (int) pluginSortMethod); + appProperties->getUserSettings()->setValue ("pluginSortMethod", (int) pluginSortMethod); } else { @@ -447,12 +440,11 @@ void MainHostWindow::showAudioSettings() XmlElement* const audioState = deviceManager.createStateXml(); - ApplicationProperties::getInstance()->getUserSettings() - ->setValue ("audioDeviceState", audioState); + appProperties->getUserSettings()->setValue ("audioDeviceState", audioState); delete audioState; - ApplicationProperties::getInstance()->getUserSettings()->saveIfNeeded(); + appProperties->getUserSettings()->saveIfNeeded(); GraphDocumentComponent* const graphEditor = getGraphEditor(); diff --git a/extras/audio plugin host/Source/MainHostWindow.h b/extras/audio plugin host/Source/MainHostWindow.h index 59e2b6d366..c05b7bca74 100644 --- a/extras/audio plugin host/Source/MainHostWindow.h +++ b/extras/audio plugin host/Source/MainHostWindow.h @@ -42,7 +42,7 @@ namespace CommandIDs } extern ApplicationCommandManager* commandManager; - +extern ApplicationProperties* appProperties; //============================================================================== /** diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index 56f58daa5d..4752930b3a 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -19907,8 +19907,6 @@ END_JUCE_NAMESPACE /*** Start of inlined file: juce_ApplicationProperties.cpp ***/ BEGIN_JUCE_NAMESPACE -juce_ImplementSingleton (ApplicationProperties) - ApplicationProperties::ApplicationProperties() : commonSettingsAreReadOnly (0) { @@ -19917,7 +19915,6 @@ ApplicationProperties::ApplicationProperties() ApplicationProperties::~ApplicationProperties() { closeFiles(); - clearSingletonInstance(); } void ApplicationProperties::setStorageParameters (const PropertiesFile::Options& newOptions) @@ -34104,11 +34101,6 @@ END_JUCE_NAMESPACE #else #include #include - - static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) - { - return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; - } #endif #if ! (JUCE_MAC && JUCE_64BIT) @@ -34119,6 +34111,13 @@ BEGIN_JUCE_NAMESPACE #endif +#if JUCE_MAC + static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) + { + return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; + } +#endif + #undef PRAGMA_ALIGN_SUPPORTED #define VST_FORCE_DEPRECATED 0 diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 9a344f9641..033af52dde 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 20 +#define JUCE_BUILDNUMBER 21 /** Current Juce version number. @@ -35029,8 +35029,7 @@ private: /** Manages a collection of properties. - This is a slightly higher-level wrapper for PropertiesFile, which can be used - as a singleton. + This is a slightly higher-level wrapper for managing PropertiesFile objects. It holds two different PropertiesFile objects internally, one for user-specific settings (stored in your user directory), and one for settings that are common to @@ -35040,13 +35039,13 @@ private: getUserSettings() and getCommonSettings() methods. It also has a few handy methods like testWriteAccess() to check that the files can be saved. - If you're using one of these as a singleton, then your app's start-up code should - first of all call setStorageParameters() to tell it the parameters to use to create - the properties files. + After creating an instance of an ApplicationProperties object, you should first + of all call setStorageParameters() to tell it the parameters to use to create + its files. @see PropertiesFile */ -class JUCE_API ApplicationProperties : public DeletedAtShutdown +class JUCE_API ApplicationProperties { public: @@ -35061,8 +35060,6 @@ public: /** Destructor. */ ~ApplicationProperties(); - juce_DeclareSingleton (ApplicationProperties, false); - /** Gives the object the information it needs to create the appropriate properties files. See the PropertiesFile::Options class for details about what options you need to set. */ @@ -37272,9 +37269,8 @@ private: A class for keeping a list of available audio formats, and for deciding which one to use to open a given file. - You can either use this class as a singleton object, or create instances of it - yourself. Once created, use its registerFormat() method to tell it which - formats it should use. + After creating an AudioFormatManager object, you should call registerFormat() + or registerBasicFormats() to give it a list of format types that it can use. @see AudioFormat */ diff --git a/src/application/juce_ApplicationProperties.cpp b/src/application/juce_ApplicationProperties.cpp index 0ef49124d3..4d0269b4cf 100644 --- a/src/application/juce_ApplicationProperties.cpp +++ b/src/application/juce_ApplicationProperties.cpp @@ -32,10 +32,6 @@ BEGIN_JUCE_NAMESPACE #include "../text/juce_LocalisedStrings.h" -//============================================================================== -juce_ImplementSingleton (ApplicationProperties) - - //============================================================================== ApplicationProperties::ApplicationProperties() : commonSettingsAreReadOnly (0) @@ -45,7 +41,6 @@ ApplicationProperties::ApplicationProperties() ApplicationProperties::~ApplicationProperties() { closeFiles(); - clearSingletonInstance(); } //============================================================================== diff --git a/src/application/juce_ApplicationProperties.h b/src/application/juce_ApplicationProperties.h index 879632b606..1083fab23b 100644 --- a/src/application/juce_ApplicationProperties.h +++ b/src/application/juce_ApplicationProperties.h @@ -27,8 +27,6 @@ #define __JUCE_APPLICATIONPROPERTIES_JUCEHEADER__ #include "../utilities/juce_PropertiesFile.h" -#include "../utilities/juce_DeletedAtShutdown.h" -#include "../core/juce_Singleton.h" #include "../memory/juce_ScopedPointer.h" @@ -36,8 +34,7 @@ /** Manages a collection of properties. - This is a slightly higher-level wrapper for PropertiesFile, which can be used - as a singleton. + This is a slightly higher-level wrapper for managing PropertiesFile objects. It holds two different PropertiesFile objects internally, one for user-specific settings (stored in your user directory), and one for settings that are common to @@ -47,13 +44,13 @@ getUserSettings() and getCommonSettings() methods. It also has a few handy methods like testWriteAccess() to check that the files can be saved. - If you're using one of these as a singleton, then your app's start-up code should - first of all call setStorageParameters() to tell it the parameters to use to create - the properties files. + After creating an instance of an ApplicationProperties object, you should first + of all call setStorageParameters() to tell it the parameters to use to create + its files. @see PropertiesFile */ -class JUCE_API ApplicationProperties : public DeletedAtShutdown +class JUCE_API ApplicationProperties { public: //============================================================================== @@ -68,9 +65,6 @@ public: /** Destructor. */ ~ApplicationProperties(); - //============================================================================== - juce_DeclareSingleton (ApplicationProperties, false); - //============================================================================== /** Gives the object the information it needs to create the appropriate properties files. See the PropertiesFile::Options class for details about what options you need to set. diff --git a/src/audio/audio_file_formats/juce_AudioFormatManager.h b/src/audio/audio_file_formats/juce_AudioFormatManager.h index 068f68b4e0..bc11583e7a 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatManager.h +++ b/src/audio/audio_file_formats/juce_AudioFormatManager.h @@ -27,7 +27,6 @@ #define __JUCE_AUDIOFORMATMANAGER_JUCEHEADER__ #include "juce_AudioFormat.h" -#include "../../core/juce_Singleton.h" #include "../../containers/juce_OwnedArray.h" @@ -36,9 +35,8 @@ A class for keeping a list of available audio formats, and for deciding which one to use to open a given file. - You can either use this class as a singleton object, or create instances of it - yourself. Once created, use its registerFormat() method to tell it which - formats it should use. + After creating an AudioFormatManager object, you should call registerFormat() + or registerBasicFormats() to give it a list of format types that it can use. @see AudioFormat */ diff --git a/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.cpp b/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.cpp index 022e799198..a6a91f782e 100644 --- a/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.cpp +++ b/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.cpp @@ -217,19 +217,6 @@ void StandaloneFilterWindow::loadState() } //============================================================================== -PropertySet* StandaloneFilterWindow::getGlobalSettings() -{ - /* If you want this class to store the plugin's settings, you can set up an - ApplicationProperties object and use this method as it is, or override this - method to return your own custom PropertySet. - - If using this method without changing it, you'll probably need to call - ApplicationProperties::setStorageParameters() in your plugin's constructor to - tell it where to save the file. - */ - return ApplicationProperties::getInstance()->getUserSettings(); -} - void StandaloneFilterWindow::showAudioSettingsDialog() { AudioDeviceSelectorComponent selectorComp (*deviceManager, diff --git a/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.h b/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.h index c477440c35..73ee87efa5 100644 --- a/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.h +++ b/src/audio/plugin_client/Standalone/juce_StandaloneFilterWindow.h @@ -60,11 +60,13 @@ public: /** Shows the audio properties dialog box modally. */ virtual void showAudioSettingsDialog(); - /** Returns the property set to use for storing the app's last state. + /** Implement this method to return the property set that should be used for storing + the plugin's state. - This will be used to store the audio set-up and the filter's last state. + This will be used to store the audio set-up and the filter's last state. You may want + to return an ApplicationProperties object. */ - virtual PropertySet* getGlobalSettings(); + virtual PropertySet* getGlobalSettings() = 0; //============================================================================== /** @internal */ diff --git a/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp b/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp index 123de311a3..bf3c97dc55 100644 --- a/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugin_host/formats/juce_VSTPluginFormat.cpp @@ -52,11 +52,6 @@ #else #include #include - - static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) - { - return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; - } #endif //============================================================================== @@ -80,7 +75,14 @@ BEGIN_JUCE_NAMESPACE #include "../../../application/juce_Application.h" #if JUCE_MAC && JUCE_SUPPORT_CARBON -#include "../../../native/mac/juce_mac_CarbonViewWrapperComponent.h" + #include "../../../native/mac/juce_mac_CarbonViewWrapperComponent.h" +#endif + +#if JUCE_MAC + static bool makeFSRefFromPath (FSRef* destFSRef, const String& path) + { + return FSPathMakeRef (reinterpret_cast (path.toUTF8().getAddress()), destFSRef, 0) == noErr; + } #endif //============================================================================== diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index 658d732fd9..af191b54ca 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 54 -#define JUCE_BUILDNUMBER 20 +#define JUCE_BUILDNUMBER 21 /** Current Juce version number. diff --git a/src/text/juce_LocalisedStrings.h b/src/text/juce_LocalisedStrings.h index 4879bc9214..f828ee1630 100644 --- a/src/text/juce_LocalisedStrings.h +++ b/src/text/juce_LocalisedStrings.h @@ -27,7 +27,6 @@ #define __JUCE_LOCALISEDSTRINGS_JUCEHEADER__ #include "juce_StringPairArray.h" -#include "../core/juce_Singleton.h" #include "../io/files/juce_File.h"