Fix the key file write path which depends on exceptions from loading before writing being swalloed.

This commit is contained in:
Adam Reichold 2016-02-21 16:44:21 +01:00
parent ad45ba6df1
commit be173412f1
2 changed files with 12 additions and 4 deletions

View File

@ -1741,7 +1741,9 @@ bool Thumbnail::readData (const Glib::ustring& fname)
try {
MyMutex::MyLock thmbLock(thumbMutex);
if (!keyFile.load_from_file (fname)) {
try {
keyFile.load_from_file (fname);
} catch (Glib::Error&) {
return false;
}
@ -1836,7 +1838,10 @@ bool Thumbnail::writeData (const Glib::ustring& fname)
try {
Glib::KeyFile keyFile;
keyFile.load_from_file (fname);
try {
keyFile.load_from_file (fname);
} catch (Glib::Error&) {}
keyFile.set_double ("LiveThumbData", "CamWBRed", camwbRed);
keyFile.set_double ("LiveThumbData", "CamWBGreen", camwbGreen);
@ -1857,7 +1862,7 @@ bool Thumbnail::writeData (const Glib::ustring& fname)
keyData = keyFile.to_data ();
} catch (Glib::Error &err) {
} catch (Glib::Error& err) {
if (options.rtSettings.verbose) {
printf("Thumbnail::writeData / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
}

View File

@ -199,7 +199,10 @@ int CacheImageData::save (const Glib::ustring& fname)
try {
Glib::KeyFile keyFile;
keyFile.load_from_file (fname);
try {
keyFile.load_from_file (fname);
} catch (Glib::Error&) {}
keyFile.set_string ("General", "MD5", md5);
keyFile.set_string ("General", "Version", VERSION); // Application's version