@@ -190,6 +190,8 @@ SettingsFile* SettingsFile::initialise()
190190
191191 isInitialised = true ;
192192
193+ FileSystemWatcher::addGlobalIgnorePath (lockFile);
194+
193195 // Check if settings file exists, if not, create the default
194196 // This is expected behaviour for first run / deleting plugdata folder
195197 // No need to alert the user to this
@@ -216,7 +218,7 @@ SettingsFile* SettingsFile::initialise()
216218
217219 auto settingsFileToUse = settingsFile;
218220 bool xmlSettings = false ;
219- if (oldSettingsFile.existsAsFile ()) {
221+ if (oldSettingsFile.existsAsFile () && !settingsFile. existsAsFile () ) {
220222 settingsFileToUse = oldSettingsFile;
221223 xmlSettings = true ;
222224 }
@@ -317,26 +319,6 @@ String SettingsFile::getKeyMap() const
317319 return memOut.toString ();
318320}
319321
320- Array<var>& SettingsFile::getThemeTree () const
321- {
322- return getProperty<VarArray>(" themes" );
323- }
324-
325- Array<var>& SettingsFile::getPathsTree () const
326- {
327- return getProperty<VarArray>(" paths" );
328- }
329-
330- Array<var>& SettingsFile::getActiveThemes () const
331- {
332- return getProperty<VarArray>(" active_themes" );
333- }
334-
335- Array<var>& SettingsFile::getLibrariesTree () const
336- {
337- return getProperty<VarArray>(" libraries" );
338- }
339-
340322DynamicObject::Ptr SettingsFile::getTheme (String const & name) const
341323{
342324 for (auto & theme : getProperty<VarArray>(" themes" )) {
@@ -386,7 +368,7 @@ void SettingsFile::initialisePathsTree()
386368 HeapArray<File> currentPaths;
387369 currentPaths.reserve (10 );
388370
389- auto & pathTree = getPathsTree ( );
371+ auto & pathTree = getProperty<VarArray>( " paths " );
390372
391373 // on iOS, the containerisation of apps leads to problems with custom search paths
392374 // So we completely reset them every time
@@ -474,7 +456,7 @@ bool SettingsFile::wantsNativeDialog() const
474456void SettingsFile::initialiseThemesTree ()
475457{
476458 // Initialise selected themes tree
477- auto selectedThemes = getActiveThemes ( );
459+ auto selectedThemes = getProperty<VarArray>( " active_themes " );
478460 auto currentTheme = getProperty<String>(" theme" );
479461
480462 if (!getTheme (currentTheme))
@@ -580,6 +562,7 @@ void SettingsFile::reloadSettings()
580562 if (acquireFileLock ()) {
581563 auto const newSettings = settingsFile.loadFileAsString ();
582564 auto const contentHash = newSettings.hashCode64 ();
565+
583566 if (contentHash == lastContentHash) {
584567 releaseFileLock ();
585568 return ;
@@ -591,6 +574,16 @@ void SettingsFile::reloadSettings()
591574 return ;
592575 }
593576
577+ for (auto & [name, var] : defaultSettings) {
578+ if (name == " themes" )
579+ {
580+ settings[" themes" ] = JSON::fromString (PlugDataLook::defaultThemesJSON);
581+ loadThemeFromDiff (*var.getArray ());
582+ continue ;
583+ }
584+ settings[name] = var;
585+ }
586+
594587 auto * jsonObject = settingsToLoad.getDynamicObject ();
595588 for (auto & var : jsonObject->getProperties ()) {
596589 if (var.name == Identifier (" themes" ))
@@ -610,11 +603,9 @@ void SettingsFile::reloadSettings()
610603 }
611604}
612605
613- void SettingsFile::fileChanged (File const file, FileSystemWatcher::FileSystemEvent fileEvent )
606+ void SettingsFile::filesystemChanged ( )
614607{
615- if (file == settingsFile) {
616- reloadSettings ();
617- }
608+ reloadSettings ();
618609}
619610
620611void SettingsFile::triggerSettingsChange (String const & name)
0 commit comments