Solving issue 1730: "Long startup time / all files on all mounts are scanned while opening". The ICC profile's directory scanning is no more recursive.

This commit is contained in:
natureh 510
2013-03-03 14:30:30 +01:00
parent 2e86d15c50
commit 602c2d42c4

View File

@@ -218,42 +218,46 @@ void ICCStore::loadICCs(Glib::ustring rootDirName, bool nameUpper, std::map<std:
qDirs.push_front(rootDirName); qDirs.push_front(rootDirName);
while (!qDirs.empty()) { while (!qDirs.empty()) {
// process directory // process directory
Glib::ustring dirname = qDirs.back(); Glib::ustring dirname = qDirs.back();
qDirs.pop_back(); qDirs.pop_back();
Glib::Dir* dir = NULL; Glib::Dir* dir = NULL;
try { try {
if (!safe_file_test (dirname, Glib::FILE_TEST_IS_DIR)) return; if (!safe_file_test (dirname, Glib::FILE_TEST_IS_DIR)) return;
dir = new Glib::Dir (dirname); dir = new Glib::Dir (dirname);
} }
catch (Glib::Exception& fe) { catch (Glib::Exception& fe) {
return; return;
} }
dirname = dirname + "/"; dirname = dirname + "/";
for (Glib::DirIterator i = dir->begin(); i!=dir->end(); ++i) { for (Glib::DirIterator i = dir->begin(); i!=dir->end(); ++i) {
Glib::ustring fname = dirname + *i; Glib::ustring fname = dirname + *i;
Glib::ustring sname = *i; Glib::ustring sname = *i;
// ignore directories // ignore directories
if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) { if (!safe_file_test (fname, Glib::FILE_TEST_IS_DIR)) {
size_t lastdot = sname.find_last_of ('.'); size_t lastdot = sname.find_last_of ('.');
if (lastdot!=Glib::ustring::npos && lastdot<=sname.size()-4 && (!sname.casefold().compare (lastdot, 4, ".icm") || !sname.casefold().compare (lastdot, 4, ".icc"))) { if (lastdot!=Glib::ustring::npos && lastdot<=sname.size()-4 && (!sname.casefold().compare (lastdot, 4, ".icm") || !sname.casefold().compare (lastdot, 4, ".icc"))) {
Glib::ustring name = nameUpper ? sname.substr(0,lastdot).uppercase() : sname.substr(0,lastdot); Glib::ustring name = nameUpper ? sname.substr(0,lastdot).uppercase() : sname.substr(0,lastdot);
ProfileContent pc (fname); ProfileContent pc (fname);
if (pc.data) { if (pc.data) {
cmsHPROFILE profile = pc.toProfile (); cmsHPROFILE profile = pc.toProfile ();
if (profile) { if (profile) {
resultProfiles[name] = profile; resultProfiles[name] = profile;
resultProfileContents[name] = pc; resultProfileContents[name] = pc;
}
} }
} }
} }
} else qDirs.push_front(fname); // for later scanning // Removed recursive scanning, see issue #1730.
// To revert to the recursive method, just uncomment the next line.
//else qDirs.push_front(fname); // for later scanning
}
delete dir;
} }
delete dir;
} }
} }
}
// Determine the first monitor default profile of operating system, if selected // Determine the first monitor default profile of operating system, if selected
void ICCStore::findDefaultMonitorProfile() { void ICCStore::findDefaultMonitorProfile() {