In a audio plugin I use a Preferences Class that looks like this:
class Preferences {
public:
Preferences ()
{
PropertiesFile::Options options;
options.applicationName = ProjectInfo::projectName;
options.osxLibrarySubFolder = "Application Support";
options.folderName = ProjectInfo::companyName;
options.filenameSuffix = ".settings";
prefs.setStorageParameters (options);
}
String getProperty (String key)
{
PropertiesFile* prefFile = prefs.getUserSettings();
jassert (prefFile->isValidFile());
String value = prefFile->getValue(key);
return value;
}
void setProperty (String key, String value)
{
PropertiesFile* prefFile = prefs.getUserSettings();
jassert (prefFile->isValidFile());
prefFile->setValue(key, value);
prefFile->saveIfNeeded();
}
ApplicationProperties prefs;
};
This class is used in 3 different Components
like this:
Preferences preferences;
String myPrefValue (preferences. getProperty(myPrefKey));
...
preferences.setProperty(myKey, myValue);
The plugins works fine until I close the hosting app, then I get the error:
*** Leaked objects detected: 2 instance(s) of class PropertiesFile
The Leaks only occure in the AudioUnit, but not in the VST3.
I do not quite understand, what’s going wrong here.
My search here in the forum just leads me to some very old topics…
Can anyone help to point me in the right direction?
Thanks!