diff --git a/rtengine/iccstore.cc b/rtengine/iccstore.cc index 8a0a8d210..a2f2b533f 100644 --- a/rtengine/iccstore.cc +++ b/rtengine/iccstore.cc @@ -264,11 +264,34 @@ cmsHPROFILE ICCStore::getStdProfile (Glib::ustring name) { MyMutex::MyLock lock(mutex_); - std::map::iterator r = fileStdProfiles.find (name.uppercase()); - if (r==fileStdProfiles.end()) return NULL; - - return r->second; + if (r==fileStdProfiles.end()) { + // profile is not yet in store + std::map::iterator f = fileStdProfilesFileNames.find (name.uppercase()); + if(f!=fileStdProfilesFileNames.end()) { + // but there exists one => load it + ProfileContent pc (f->second); + if (pc.data) { + cmsHPROFILE profile = pc.toProfile (); + if (profile) { + fileStdProfiles[name.uppercase()] = profile; + } + // profile is not valid or it is now stored => remove entry from fileStdProfilesFileNames + fileStdProfilesFileNames.erase(f); + return profile; + } else { + // profile not valid => remove entry from fileStdProfilesFileNames + fileStdProfilesFileNames.erase(f); + return NULL; + } + } else { + // profile does not exist + return NULL; + } + } else { + // return profile from store + return r->second; + } } ProfileContent ICCStore::getContent (Glib::ustring name) { @@ -287,17 +310,17 @@ void ICCStore::init (Glib::ustring usrICCDir, Glib::ustring rtICCDir) { fileProfiles.clear(); fileProfileContents.clear(); // RawTherapee's profiles take precedence if a user's profile of the same name exists - loadICCs(Glib::build_filename(rtICCDir, "output"), false, fileProfiles, fileProfileContents, true); - loadICCs(usrICCDir, false, fileProfiles, fileProfileContents, true); + loadICCs(Glib::build_filename(rtICCDir, "output"), false, fileProfiles, &fileProfileContents, true, true); + loadICCs(usrICCDir, false, fileProfiles, &fileProfileContents, true, true); // Input profiles // Load these to different areas, since the short name (e.g. "NIKON D700" may overlap between system/user and RT dir) fileStdProfiles.clear(); - fileStdProfileContents.clear(); - loadICCs(Glib::build_filename(rtICCDir, "input"), true, fileStdProfiles, fileStdProfileContents); + fileStdProfilesFileNames.clear(); + loadICCs(Glib::build_filename(rtICCDir, "input"), true, fileStdProfiles, NULL); } -void ICCStore::loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map& resultProfiles, std::map &resultProfileContents, bool onlyRgb) { +void ICCStore::loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map& resultProfiles, std::map *resultProfileContents, bool prefetch, bool onlyRgb) { if (rootDirName!="") { std::deque qDirs; @@ -325,12 +348,17 @@ void ICCStore::loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map fileProfileContents; // these contain standard profiles from RT. keys are all in uppercase + std::map fileStdProfilesFileNames; std::map fileStdProfiles; - std::map fileStdProfileContents; cmsHPROFILE xyz; cmsHPROFILE srgb; @@ -65,7 +65,7 @@ class ICCStore { MyMutex mutex_; ICCStore (); - void loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map& resultProfiles, std::map &resultProfileContents, bool onlyRgb = false); + void loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map& resultProfiles, std::map *resultProfileContents, bool prefetch = false, bool onlyRgb = false); public: