diff --git a/rtengine/profilestore.cc b/rtengine/profilestore.cc index 984ab9423..12c1cca5c 100644 --- a/rtengine/profilestore.cc +++ b/rtengine/profilestore.cc @@ -46,7 +46,7 @@ bool ProfileStore::init (bool loadAll) this->loadAll = loadAll; - if (storeState == STORESTATE_NOTINITIALIZED && loadAll) { + if ((storeState == STORESTATE_NOTINITIALIZED || storeState == STORESTATE_DIRTY) && loadAll) { storeState = STORESTATE_BEINGINITIALIZED; _parseProfiles (); storeState = STORESTATE_INITIALIZED; @@ -85,7 +85,7 @@ ProfileStore::~ProfileStore () * This method will scan the directory tree again and update the profile list. When finished, * the listeners will be called in order to update with the new list */ -void ProfileStore::parseProfiles () +void ProfileStore::parseProfilesOnce () { for (auto listener : listeners) { @@ -100,6 +100,13 @@ void ProfileStore::parseProfiles () } } +void ProfileStore::parseProfiles () +{ + + storeState = STORESTATE_DIRTY; + parseProfilesOnce (); +} + void ProfileStore::_parseProfiles () { // clear loaded profiles @@ -272,7 +279,7 @@ const ProfileStoreEntry* ProfileStore::findEntryFromFullPathU (Glib::ustring pat } if (storeState == STORESTATE_NOTINITIALIZED) { - parseProfiles(); + parseProfilesOnce(); } if (path == DEFPROFILE_INTERNAL || path == DEFPROFILE_DYNAMIC) { @@ -340,7 +347,7 @@ const PartialProfile* ProfileStore::getProfile (Glib::ustring path) { if (storeState == STORESTATE_NOTINITIALIZED) { - parseProfiles(); + parseProfilesOnce(); } const ProfileStoreEntry *pse = findEntryFromFullPath (path); @@ -356,7 +363,7 @@ const PartialProfile* ProfileStore::getProfile (const ProfileStoreEntry* entry) { if (storeState == STORESTATE_NOTINITIALIZED) { - parseProfiles(); + parseProfilesOnce(); } MyMutex::MyLock lock (parseMutex); @@ -387,7 +394,7 @@ const std::vector* ProfileStore::getFileList () { if (storeState == STORESTATE_NOTINITIALIZED) { - parseProfiles(); + parseProfilesOnce(); } parseMutex.lock(); @@ -493,7 +500,7 @@ void ProfileStore::dumpFolderList() PartialProfile *ProfileStore::loadDynamicProfile (const ImageMetaData *im) { if (storeState == STORESTATE_NOTINITIALIZED) { - parseProfiles(); + parseProfilesOnce(); } PartialProfile *ret = new PartialProfile (true, true); diff --git a/rtengine/profilestore.h b/rtengine/profilestore.h index c6627b4c8..372dbfc3b 100644 --- a/rtengine/profilestore.h +++ b/rtengine/profilestore.h @@ -106,6 +106,7 @@ class ProfileStore : public rtengine::NonCopyable, public DynamicProfileRules STORESTATE_LIGHTWEIGHT, STORESTATE_BEINGINITIALIZED, STORESTATE_INITIALIZED, + STORESTATE_DIRTY, STORESTATE_DELETED } StoreState; @@ -153,6 +154,11 @@ private: * if false, only one root directory is expected */ bool parseDir (Glib::ustring& realPath, Glib::ustring& virtualPath, Glib::ustring& currDir, unsigned int parentId, unsigned char level, bool displayLevel0); + /** @brief Will parse the profiles's dir only once. Subsequent call to this function will be ignored unless the profile list has been cleared + */ + void parseProfilesOnce (); + /** @brief Will scan the directory to fill the profile list + */ void _parseProfiles (); void clearFileList (); void clearProfileList ();