Also remove the SafeKeyFile wrapper class.
This commit is contained in:
parent
a2eea7c265
commit
85c809ce6c
@ -19,7 +19,6 @@
|
|||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include "procparams.h"
|
#include "procparams.h"
|
||||||
#include "rt_math.h"
|
#include "rt_math.h"
|
||||||
#include "safekeyfile.h"
|
|
||||||
#include "dcp.h"
|
#include "dcp.h"
|
||||||
#include "../rtgui/multilangmgr.h"
|
#include "../rtgui/multilangmgr.h"
|
||||||
#include "../rtgui/version.h"
|
#include "../rtgui/version.h"
|
||||||
@ -1302,11 +1301,15 @@ static Glib::ustring relativePathIfInside(Glib::ustring procparams_fname, bool f
|
|||||||
int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsolute, ParamsEdited* pedited)
|
int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsolute, ParamsEdited* pedited)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!fname.length() && !fname2.length()) {
|
if (fname.empty () && fname2.empty ()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeKeyFile keyFile;
|
Glib::ustring sPParams;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
keyFile.set_string ("Version", "AppVersion", APPVERSION);
|
keyFile.set_string ("Version", "AppVersion", APPVERSION);
|
||||||
keyFile.set_integer ("Version", "Version", PPVERSION);
|
keyFile.set_integer ("Version", "Version", PPVERSION);
|
||||||
@ -3362,12 +3365,18 @@ int ProcParams::save (Glib::ustring fname, Glib::ustring fname2, bool fnameAbsol
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Glib::ustring sPParams = keyFile.to_data();
|
sPParams = keyFile.to_data();
|
||||||
|
|
||||||
|
} catch(Glib::KeyFileError&) {}
|
||||||
|
|
||||||
|
if (sPParams.empty ()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int error1, error2;
|
int error1, error2;
|
||||||
error1 = write (fname , sPParams);
|
error1 = write (fname, sPParams);
|
||||||
|
|
||||||
if (fname2.length()) {
|
if (!fname2.empty ()) {
|
||||||
|
|
||||||
error2 = write (fname2, sPParams);
|
error2 = write (fname2, sPParams);
|
||||||
// If at least one file has been saved, it's a success
|
// If at least one file has been saved, it's a success
|
||||||
@ -3405,10 +3414,10 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeKeyFile keyFile;
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//setDefaults ();
|
|
||||||
if (pedited) {
|
if (pedited) {
|
||||||
pedited->set(false);
|
pedited->set(false);
|
||||||
}
|
}
|
||||||
@ -3449,8 +3458,6 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("ProcParams::load called ppVersion=%i\n",ppVersion);
|
|
||||||
|
|
||||||
if (keyFile.has_group ("General")) {
|
if (keyFile.has_group ("General")) {
|
||||||
if (keyFile.has_key ("General", "Rank")) {
|
if (keyFile.has_key ("General", "Rank")) {
|
||||||
rank = keyFile.get_integer ("General", "Rank");
|
rank = keyFile.get_integer ("General", "Rank");
|
||||||
@ -7426,9 +7433,11 @@ int ProcParams::load (Glib::ustring fname, ParamsEdited* pedited)
|
|||||||
return 0;
|
return 0;
|
||||||
} catch (const Glib::Error& e) {
|
} catch (const Glib::Error& e) {
|
||||||
printf ("-->%s\n", e.what().c_str());
|
printf ("-->%s\n", e.what().c_str());
|
||||||
|
setDefaults ();
|
||||||
return 1;
|
return 1;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
printf ("-->unknown exception!\n");
|
printf ("-->unknown exception!\n");
|
||||||
|
setDefaults ();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
#include "stdimagesource.h"
|
#include "stdimagesource.h"
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <csetjmp>
|
#include <csetjmp>
|
||||||
#include "safekeyfile.h"
|
|
||||||
#include "rawimage.h"
|
#include "rawimage.h"
|
||||||
#include "jpeg.h"
|
#include "jpeg.h"
|
||||||
#include "../rtgui/ppversion.h"
|
#include "../rtgui/ppversion.h"
|
||||||
@ -1737,7 +1736,7 @@ bool Thumbnail::readImage (const Glib::ustring& fname)
|
|||||||
bool Thumbnail::readData (const Glib::ustring& fname)
|
bool Thumbnail::readData (const Glib::ustring& fname)
|
||||||
{
|
{
|
||||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||||
SafeKeyFile keyFile;
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
MyMutex::MyLock thmbLock(thumbMutex);
|
MyMutex::MyLock thmbLock(thumbMutex);
|
||||||
@ -1830,15 +1829,34 @@ bool Thumbnail::readData (const Glib::ustring& fname)
|
|||||||
|
|
||||||
bool Thumbnail::writeData (const Glib::ustring& fname)
|
bool Thumbnail::writeData (const Glib::ustring& fname)
|
||||||
{
|
{
|
||||||
|
|
||||||
SafeKeyFile keyFile;
|
|
||||||
|
|
||||||
MyMutex::MyLock thmbLock(thumbMutex);
|
MyMutex::MyLock thmbLock(thumbMutex);
|
||||||
|
|
||||||
|
Glib::ustring keyData;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if( Glib::file_test(fname, Glib::FILE_TEST_EXISTS) ) {
|
|
||||||
keyFile.load_from_file (fname);
|
Glib::KeyFile keyFile;
|
||||||
}
|
keyFile.load_from_file (fname);
|
||||||
|
|
||||||
|
keyFile.set_double ("LiveThumbData", "CamWBRed", camwbRed);
|
||||||
|
keyFile.set_double ("LiveThumbData", "CamWBGreen", camwbGreen);
|
||||||
|
keyFile.set_double ("LiveThumbData", "CamWBBlue", camwbBlue);
|
||||||
|
keyFile.set_double ("LiveThumbData", "RedAWBMul", redAWBMul);
|
||||||
|
keyFile.set_double ("LiveThumbData", "GreenAWBMul", greenAWBMul);
|
||||||
|
keyFile.set_double ("LiveThumbData", "BlueAWBMul", blueAWBMul);
|
||||||
|
keyFile.set_integer ("LiveThumbData", "AEHistCompression", aeHistCompression);
|
||||||
|
keyFile.set_double ("LiveThumbData", "RedMultiplier", redMultiplier);
|
||||||
|
keyFile.set_double ("LiveThumbData", "GreenMultiplier", greenMultiplier);
|
||||||
|
keyFile.set_double ("LiveThumbData", "BlueMultiplier", blueMultiplier);
|
||||||
|
keyFile.set_double ("LiveThumbData", "Scale", scale);
|
||||||
|
keyFile.set_double ("LiveThumbData", "DefaultGain", defGain);
|
||||||
|
keyFile.set_integer ("LiveThumbData", "ScaleForSave", scaleForSave);
|
||||||
|
keyFile.set_boolean ("LiveThumbData", "GammaCorrected", gammaCorrected);
|
||||||
|
Glib::ArrayHandle<double> cm ((double*)colorMatrix, 9, Glib::OWNERSHIP_NONE);
|
||||||
|
keyFile.set_double_list ("LiveThumbData", "ColorMatrix", cm);
|
||||||
|
|
||||||
|
keyData = keyFile.to_data ();
|
||||||
|
|
||||||
} catch (Glib::Error &err) {
|
} catch (Glib::Error &err) {
|
||||||
if (options.rtSettings.verbose) {
|
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());
|
printf("Thumbnail::writeData / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
||||||
@ -1849,22 +1867,9 @@ bool Thumbnail::writeData (const Glib::ustring& fname)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyFile.set_double ("LiveThumbData", "CamWBRed", camwbRed);
|
if (keyData.empty ()) {
|
||||||
keyFile.set_double ("LiveThumbData", "CamWBGreen", camwbGreen);
|
return false;
|
||||||
keyFile.set_double ("LiveThumbData", "CamWBBlue", camwbBlue);
|
}
|
||||||
keyFile.set_double ("LiveThumbData", "RedAWBMul", redAWBMul);
|
|
||||||
keyFile.set_double ("LiveThumbData", "GreenAWBMul", greenAWBMul);
|
|
||||||
keyFile.set_double ("LiveThumbData", "BlueAWBMul", blueAWBMul);
|
|
||||||
keyFile.set_integer ("LiveThumbData", "AEHistCompression", aeHistCompression);
|
|
||||||
keyFile.set_double ("LiveThumbData", "RedMultiplier", redMultiplier);
|
|
||||||
keyFile.set_double ("LiveThumbData", "GreenMultiplier", greenMultiplier);
|
|
||||||
keyFile.set_double ("LiveThumbData", "BlueMultiplier", blueMultiplier);
|
|
||||||
keyFile.set_double ("LiveThumbData", "Scale", scale);
|
|
||||||
keyFile.set_double ("LiveThumbData", "DefaultGain", defGain);
|
|
||||||
keyFile.set_integer ("LiveThumbData", "ScaleForSave", scaleForSave);
|
|
||||||
keyFile.set_boolean ("LiveThumbData", "GammaCorrected", gammaCorrected);
|
|
||||||
Glib::ArrayHandle<double> cm ((double*)colorMatrix, 9, Glib::OWNERSHIP_NONE);
|
|
||||||
keyFile.set_double_list ("LiveThumbData", "ColorMatrix", cm);
|
|
||||||
|
|
||||||
FILE *f = g_fopen (fname.c_str (), "wt");
|
FILE *f = g_fopen (fname.c_str (), "wt");
|
||||||
|
|
||||||
@ -1875,7 +1880,7 @@ bool Thumbnail::writeData (const Glib::ustring& fname)
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
fprintf (f, "%s", keyFile.to_data().c_str());
|
fprintf (f, "%s", keyData.c_str ());
|
||||||
fclose (f);
|
fclose (f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,117 +0,0 @@
|
|||||||
#ifndef SAFE_KEY_FILE_H_INCLUDED
|
|
||||||
#define SAFE_KEY_FILE_H_INCLUDED
|
|
||||||
|
|
||||||
#include <glibmm.h>
|
|
||||||
namespace rtengine
|
|
||||||
{
|
|
||||||
|
|
||||||
class SafeKeyFile : public Glib::KeyFile
|
|
||||||
{
|
|
||||||
public :
|
|
||||||
|
|
||||||
#ifdef GLIBMM_EXCEPTIONS_ENABLED
|
|
||||||
#define SAFE_KEY_FILE_METHOD_CODE(method,method_err) \
|
|
||||||
do { try { res = Glib::KeyFile::method; }catch (const Glib::KeyFileError& e) { } ; \
|
|
||||||
return res; }while(0)
|
|
||||||
#else
|
|
||||||
#define SAFE_KEY_FILE_METHOD_CODE(method,method_err) \
|
|
||||||
do { std::auto_ptr<Glib::Error> error; \
|
|
||||||
res = Glib::KeyFile::method_err; \
|
|
||||||
if (error.get()){/* TODO */}; \
|
|
||||||
return res;} while(0)
|
|
||||||
#endif //GLIBMM_EXCEPTIONS_ENABLED
|
|
||||||
#define SAFE_KEY_FILE_METHOD(method,method_err,ret_type) \
|
|
||||||
{ ret_type res = (ret_type)0; SAFE_KEY_FILE_METHOD_CODE(method,method_err);}
|
|
||||||
|
|
||||||
#define SAFE_KEY_FILE_METHOD_NOINIT(method,method_err,ret_type) \
|
|
||||||
{ ret_type res; SAFE_KEY_FILE_METHOD_CODE(method,method_err);}
|
|
||||||
|
|
||||||
Glib::ustring to_data()
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(to_data(), to_data(error), Glib::ustring);
|
|
||||||
|
|
||||||
bool load_from_data(const Glib::ustring& data, Glib::KeyFileFlags flags = Glib::KEY_FILE_NONE)
|
|
||||||
SAFE_KEY_FILE_METHOD(load_from_data(data, flags), load_from_data(data, flags, error), bool);
|
|
||||||
|
|
||||||
bool load_from_file(const std::string& filename, Glib::KeyFileFlags flags = Glib::KEY_FILE_NONE)
|
|
||||||
SAFE_KEY_FILE_METHOD(load_from_file(filename, flags), load_from_file(filename, flags, error), bool);
|
|
||||||
|
|
||||||
bool has_key(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD(has_key(group_name, key), has_key(group_name, key, error), bool);
|
|
||||||
|
|
||||||
bool get_boolean(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD(get_boolean(group_name, key), get_boolean(group_name, key, error), bool);
|
|
||||||
|
|
||||||
int get_integer(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD(get_integer(group_name, key), get_integer(group_name, key, error), int);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
double get_double(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD(get_double(group_name, key), get_double(group_name, key, error), double);
|
|
||||||
|
|
||||||
typedef std::vector<double> DoubleArrayType;
|
|
||||||
|
|
||||||
DoubleArrayType get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(get_double_list(group_name, key), get_double_list(group_name, key, error), DoubleArrayType);
|
|
||||||
|
|
||||||
typedef std::vector<int> IntArrayType;
|
|
||||||
|
|
||||||
IntArrayType get_integer_list(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(get_integer_list(group_name, key), get_integer_list(group_name, key, error), IntArrayType);
|
|
||||||
|
|
||||||
Glib::ustring get_string(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(get_string(group_name, key), get_string(group_name, key, error), Glib::ustring);
|
|
||||||
/*
|
|
||||||
double get_double(const Glib::ustring& group_name, const Glib::ustring& key) const {
|
|
||||||
Glib::ustring temp = get_string( group_name, key);
|
|
||||||
if(!temp.empty()) {
|
|
||||||
double tmpdbl;
|
|
||||||
if(sscanf(temp.c_str(), "%lf", &tmpdbl))
|
|
||||||
return tmpdbl;
|
|
||||||
else
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
typedef std::vector<Glib::ustring> StringArrayType;
|
|
||||||
|
|
||||||
StringArrayType get_string_list(const Glib::ustring& group_name, const Glib::ustring& key) const
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(get_string_list(group_name, key), get_string_list(group_name, key, error), StringArrayType);
|
|
||||||
/*
|
|
||||||
typedef std::vector<double> DoubleArrayType;
|
|
||||||
|
|
||||||
DoubleArrayType get_double_list(const Glib::ustring& group_name, const Glib::ustring& key) const {
|
|
||||||
StringArrayType temp = get_string_list(group_name, key);
|
|
||||||
DoubleArrayType tempdouble;
|
|
||||||
unsigned int n = temp.size();
|
|
||||||
if(n) {
|
|
||||||
tempdouble.reserve(n);
|
|
||||||
for (unsigned int i=0; i<n; i++) {
|
|
||||||
if(!temp[i].empty()) {
|
|
||||||
double tmpdbl;
|
|
||||||
if(sscanf(temp[i].c_str(), "%lf", &tmpdbl))
|
|
||||||
tempdouble.push_back(tmpdbl);
|
|
||||||
else
|
|
||||||
tempdouble.push_back(0.0);
|
|
||||||
} else {
|
|
||||||
tempdouble.push_back(0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tempdouble;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
StringArrayType get_keys(const Glib::ustring& group_name) const
|
|
||||||
SAFE_KEY_FILE_METHOD_NOINIT(get_keys(group_name), get_keys(group_name, error), StringArrayType);
|
|
||||||
|
|
||||||
#undef SAFE_KEY_FILE_METHOD_CODE
|
|
||||||
#undef SAFE_KEY_FILE_METHOD
|
|
||||||
#undef SAFE_KEY_FILE_METHOD_NOINIT
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -249,17 +249,10 @@ void TagDirectory::printAll (unsigned int level) const
|
|||||||
*
|
*
|
||||||
* @return True if everything went fine, false otherwise
|
* @return True if everything went fine, false otherwise
|
||||||
*/
|
*/
|
||||||
bool TagDirectory::CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams, const CacheImageData* cfs, const bool flagMode,
|
bool TagDirectory::CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams,
|
||||||
rtengine::SafeKeyFile *keyFile, Glib::ustring tagDirName) const
|
const CacheImageData* cfs, const bool flagMode, Glib::KeyFile *keyFile, Glib::ustring tagDirName) const
|
||||||
{
|
{
|
||||||
|
const auto kf = keyFile ? keyFile : new Glib::KeyFile;
|
||||||
rtengine::SafeKeyFile *kf;
|
|
||||||
|
|
||||||
if (!keyFile) {
|
|
||||||
kf = new rtengine::SafeKeyFile();
|
|
||||||
} else {
|
|
||||||
kf = keyFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!kf) {
|
if (!kf) {
|
||||||
return false;
|
return false;
|
||||||
@ -284,21 +277,25 @@ bool TagDirectory::CPBDump (const Glib::ustring &commFName, const Glib::ustring
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
kf->set_string ("RT General", "CachePath", options.cacheBaseDir);
|
try {
|
||||||
kf->set_string ("RT General", "AppVersion", VERSION);
|
|
||||||
kf->set_integer("RT General", "ProcParamsVersion", PPVERSION);
|
|
||||||
kf->set_string ("RT General", "ImageFileName", imageFName);
|
|
||||||
kf->set_string ("RT General", "OutputProfileFileName", profileFName);
|
|
||||||
kf->set_string ("RT General", "DefaultProcParams", defaultPParams);
|
|
||||||
kf->set_boolean("RT General", "FlaggingMode", flagMode);
|
|
||||||
|
|
||||||
kf->set_double ("Common Data", "FNumber", cfs->fnumber);
|
kf->set_string ("RT General", "CachePath", options.cacheBaseDir);
|
||||||
kf->set_double ("Common Data", "Shutter", cfs->shutter);
|
kf->set_string ("RT General", "AppVersion", VERSION);
|
||||||
kf->set_double ("Common Data", "FocalLength", cfs->focalLen);
|
kf->set_integer("RT General", "ProcParamsVersion", PPVERSION);
|
||||||
kf->set_integer("Common Data", "ISO", cfs->iso);
|
kf->set_string ("RT General", "ImageFileName", imageFName);
|
||||||
kf->set_string ("Common Data", "Lens", cfs->lens);
|
kf->set_string ("RT General", "OutputProfileFileName", profileFName);
|
||||||
kf->set_string ("Common Data", "Make", cfs->camMake);
|
kf->set_string ("RT General", "DefaultProcParams", defaultPParams);
|
||||||
kf->set_string ("Common Data", "Model", cfs->camModel);
|
kf->set_boolean("RT General", "FlaggingMode", flagMode);
|
||||||
|
|
||||||
|
kf->set_double ("Common Data", "FNumber", cfs->fnumber);
|
||||||
|
kf->set_double ("Common Data", "Shutter", cfs->shutter);
|
||||||
|
kf->set_double ("Common Data", "FocalLength", cfs->focalLen);
|
||||||
|
kf->set_integer("Common Data", "ISO", cfs->iso);
|
||||||
|
kf->set_string ("Common Data", "Lens", cfs->lens);
|
||||||
|
kf->set_string ("Common Data", "Make", cfs->camMake);
|
||||||
|
kf->set_string ("Common Data", "Model", cfs->camModel);
|
||||||
|
|
||||||
|
} catch (Glib::KeyFileError&) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recursively iterate over the tag list
|
// recursively iterate over the tag list
|
||||||
@ -310,10 +307,15 @@ bool TagDirectory::CPBDump (const Glib::ustring &commFName, const Glib::ustring
|
|||||||
// Accumulating the TagDirectories to dump later
|
// Accumulating the TagDirectories to dump later
|
||||||
tagDirPaths.push_back( Glib::ustring( tagDirName + "/" + getDumpKey(tags[i]->getID(), tagName) ) );
|
tagDirPaths.push_back( Glib::ustring( tagDirName + "/" + getDumpKey(tags[i]->getID(), tagName) ) );
|
||||||
tagDirList.push_back(tags[i]->getDirectory(j));
|
tagDirList.push_back(tags[i]->getDirectory(j));
|
||||||
kf->set_string (tagDirName, getDumpKey(tags[i]->getID(), tagName), "$subdir");
|
|
||||||
|
try {
|
||||||
|
kf->set_string (tagDirName, getDumpKey(tags[i]->getID(), tagName), "$subdir");
|
||||||
|
} catch (Glib::KeyFileError&) {}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
kf->set_string (tagDirName, getDumpKey(tags[i]->getID(), tagName), tags[i]->valueToString());
|
try {
|
||||||
|
kf->set_string (tagDirName, getDumpKey(tags[i]->getID(), tagName), tags[i]->valueToString());
|
||||||
|
} catch (Glib::KeyFileError&) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +325,10 @@ bool TagDirectory::CPBDump (const Glib::ustring &commFName, const Glib::ustring
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!keyFile) {
|
if (!keyFile) {
|
||||||
fprintf (f, "%s", kf->to_data().c_str());
|
try {
|
||||||
|
fprintf (f, "%s", kf->to_data().c_str());
|
||||||
|
} catch (Glib::KeyFileError&) {}
|
||||||
|
|
||||||
fclose (f);
|
fclose (f);
|
||||||
delete kf;
|
delete kf;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <glibmm.h>
|
#include <glibmm.h>
|
||||||
#include "../rtengine/procparams.h"
|
#include "../rtengine/procparams.h"
|
||||||
#include "../rtengine/safekeyfile.h"
|
|
||||||
|
|
||||||
class CacheImageData;
|
class CacheImageData;
|
||||||
|
|
||||||
@ -156,7 +155,7 @@ public:
|
|||||||
|
|
||||||
virtual void printAll (unsigned int level = 0) const; // reentrant debug function, keep level=0 on first call !
|
virtual void printAll (unsigned int level = 0) const; // reentrant debug function, keep level=0 on first call !
|
||||||
virtual bool CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams,
|
virtual bool CPBDump (const Glib::ustring &commFName, const Glib::ustring &imageFName, const Glib::ustring &profileFName, const Glib::ustring &defaultPParams,
|
||||||
const CacheImageData* cfs, const bool flagMode, rtengine::SafeKeyFile *keyFile = NULL, Glib::ustring tagDirName = "") const;
|
const CacheImageData* cfs, const bool flagMode, Glib::KeyFile *keyFile = NULL, Glib::ustring tagDirName = "") const;
|
||||||
virtual void sort ();
|
virtual void sort ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include "cacheimagedata.h"
|
#include "cacheimagedata.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include "../rtengine/safekeyfile.h"
|
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
@ -35,7 +34,8 @@ CacheImageData::CacheImageData ()
|
|||||||
int CacheImageData::load (const Glib::ustring& fname)
|
int CacheImageData::load (const Glib::ustring& fname)
|
||||||
{
|
{
|
||||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||||
rtengine::SafeKeyFile keyFile;
|
|
||||||
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (keyFile.load_from_file (fname)) {
|
if (keyFile.load_from_file (fname)) {
|
||||||
@ -194,21 +194,12 @@ int CacheImageData::load (const Glib::ustring& fname)
|
|||||||
int CacheImageData::save (const Glib::ustring& fname)
|
int CacheImageData::save (const Glib::ustring& fname)
|
||||||
{
|
{
|
||||||
|
|
||||||
rtengine::SafeKeyFile keyFile;
|
Glib::ustring keyData;
|
||||||
|
|
||||||
if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
|
try {
|
||||||
try {
|
|
||||||
keyFile.load_from_file (fname);
|
Glib::KeyFile keyFile;
|
||||||
} catch (Glib::Error &err) {
|
keyFile.load_from_file (fname);
|
||||||
if (options.rtSettings.verbose) {
|
|
||||||
printf("CacheImageData::save / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
|
||||||
}
|
|
||||||
} catch (...) {
|
|
||||||
if (options.rtSettings.verbose) {
|
|
||||||
printf("CacheImageData::save / Unknown exception while trying to save \"%s\"!\n", fname.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
keyFile.set_string ("General", "MD5", md5);
|
keyFile.set_string ("General", "MD5", md5);
|
||||||
keyFile.set_string ("General", "Version", VERSION); // Application's version
|
keyFile.set_string ("General", "Version", VERSION); // Application's version
|
||||||
@ -256,6 +247,22 @@ int CacheImageData::save (const Glib::ustring& fname)
|
|||||||
keyFile.set_integer ("ExtraRawInfo", "ThumbImageOffset", thumbOffset);
|
keyFile.set_integer ("ExtraRawInfo", "ThumbImageOffset", thumbOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyData = keyFile.to_data ();
|
||||||
|
|
||||||
|
} catch (Glib::Error &err) {
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
printf("CacheImageData::save / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
if (options.rtSettings.verbose) {
|
||||||
|
printf("CacheImageData::save / Unknown exception while trying to save \"%s\"!\n", fname.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyData.empty ()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *f = g_fopen (fname.c_str (), "wt");
|
FILE *f = g_fopen (fname.c_str (), "wt");
|
||||||
|
|
||||||
if (!f) {
|
if (!f) {
|
||||||
@ -265,7 +272,7 @@ int CacheImageData::save (const Glib::ustring& fname)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf (f, "%s", keyFile.to_data().c_str());
|
fprintf (f, "%s", keyData.c_str ());
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "multilangmgr.h"
|
#include "multilangmgr.h"
|
||||||
#include "../rtengine/safekeyfile.h"
|
|
||||||
#include "addsetids.h"
|
#include "addsetids.h"
|
||||||
#include "guiutils.h"
|
#include "guiutils.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -726,7 +725,8 @@ void Options::filterOutParsedExtensions ()
|
|||||||
int Options::readFromFile (Glib::ustring fname)
|
int Options::readFromFile (Glib::ustring fname)
|
||||||
{
|
{
|
||||||
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
setlocale(LC_NUMERIC, "C"); // to set decimal point to "."
|
||||||
rtengine::SafeKeyFile keyFile;
|
|
||||||
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
if( !Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
|
if( !Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -1778,23 +1778,29 @@ int Options::readFromFile (Glib::ustring fname)
|
|||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
printf("Options::readFromFile / Error code %d while reading values from \"%s\":\n%s\n", err.code(), fname.c_str(), err.what().c_str());
|
||||||
}
|
}
|
||||||
|
setDefaults ();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
if (options.rtSettings.verbose) {
|
if (options.rtSettings.verbose) {
|
||||||
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
|
printf("Options::readFromFile / Unknown exception while trying to load \"%s\"!\n", fname.c_str());
|
||||||
}
|
}
|
||||||
|
setDefaults ();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Options::safeDirGet(const rtengine::SafeKeyFile& keyFile, const Glib::ustring& section,
|
bool Options::safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section,
|
||||||
const Glib::ustring& entryName, Glib::ustring& destination)
|
const Glib::ustring& entryName, Glib::ustring& destination)
|
||||||
{
|
{
|
||||||
if (keyFile.has_key(section, entryName) && !keyFile.get_string(section, entryName).empty()) {
|
try {
|
||||||
destination = keyFile.get_string(section, entryName);
|
|
||||||
return true;
|
if (keyFile.has_key (section, entryName) && !keyFile.get_string (section, entryName).empty ()) {
|
||||||
}
|
destination = keyFile.get_string (section, entryName);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(Glib::KeyFileError&) {}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1802,9 +1808,13 @@ bool Options::safeDirGet(const rtengine::SafeKeyFile& keyFile, const Glib::ustri
|
|||||||
int Options::saveToFile (Glib::ustring fname)
|
int Options::saveToFile (Glib::ustring fname)
|
||||||
{
|
{
|
||||||
|
|
||||||
rtengine::SafeKeyFile keyFile;
|
Glib::ustring keyData;
|
||||||
keyFile.set_boolean ("General", "TabbedEditor", tabbedUI);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Glib::KeyFile keyFile;
|
||||||
|
|
||||||
|
keyFile.set_boolean ("General", "TabbedEditor", tabbedUI);
|
||||||
keyFile.set_boolean ("General", "StoreLastProfile", savesParamsAtExit);
|
keyFile.set_boolean ("General", "StoreLastProfile", savesParamsAtExit);
|
||||||
|
|
||||||
if (startupDir == STARTUPDIR_HOME) {
|
if (startupDir == STARTUPDIR_HOME) {
|
||||||
@ -2104,6 +2114,14 @@ int Options::saveToFile (Glib::ustring fname)
|
|||||||
keyFile.set_string ("Dialogs", "LastVibranceCurvesDir", lastVibranceCurvesDir);
|
keyFile.set_string ("Dialogs", "LastVibranceCurvesDir", lastVibranceCurvesDir);
|
||||||
keyFile.set_string ("Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir);
|
keyFile.set_string ("Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir);
|
||||||
|
|
||||||
|
keyData = keyFile.to_data ();
|
||||||
|
|
||||||
|
} catch (Glib::KeyFileError&) {}
|
||||||
|
|
||||||
|
if (keyData.empty ()) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
FILE *f = g_fopen (fname.c_str (), "wt");
|
FILE *f = g_fopen (fname.c_str (), "wt");
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
@ -2113,7 +2131,7 @@ int Options::saveToFile (Glib::ustring fname)
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf (f, "%s", keyFile.to_data().c_str());
|
fprintf (f, "%s", keyData.c_str ());
|
||||||
fclose (f);
|
fclose (f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,6 @@ enum PPLoadLocation {PLL_Cache = 0, PLL_Input = 1};
|
|||||||
enum CPBKeyType {CPBKT_TID = 0, CPBKT_NAME = 1, CPBKT_TID_NAME = 2};
|
enum CPBKeyType {CPBKT_TID = 0, CPBKT_NAME = 1, CPBKT_TID_NAME = 2};
|
||||||
enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0};
|
enum prevdemo_t {PD_Sidecar = 1, PD_Fast = 0};
|
||||||
|
|
||||||
namespace rtengine
|
|
||||||
{
|
|
||||||
class SafeKeyFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
class Options
|
class Options
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -87,7 +82,7 @@ private:
|
|||||||
* @param destination destination variable to store to
|
* @param destination destination variable to store to
|
||||||
* @return @c true if @p destination was changed
|
* @return @c true if @p destination was changed
|
||||||
*/
|
*/
|
||||||
bool safeDirGet(const rtengine::SafeKeyFile& keyFile, const Glib::ustring& section,
|
bool safeDirGet(const Glib::KeyFile& keyFile, const Glib::ustring& section,
|
||||||
const Glib::ustring& entryName, Glib::ustring& destination);
|
const Glib::ustring& entryName, Glib::ustring& destination);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user