From 5b3d60bf56e14442eede054473e8457d2d2fc606 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Thu, 14 Sep 2017 10:42:01 +0200 Subject: [PATCH 1/5] lensfun: applied Floessie's workaround for locale conversion issues --- rtengine/rtlensfun.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 87a7272e9..b42be9424 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -175,7 +175,7 @@ float LFCamera::getCropFactor() const Glib::ustring LFCamera::getDisplayString() const { if (data_) { - return Glib::ustring::compose("%1 %2", getMake(), getModel()); + return getMake() + ' ' + getModel(); } else { return "---"; } @@ -211,7 +211,7 @@ Glib::ustring LFLens::getMake() const Glib::ustring LFLens::getLens() const { if (data_) { - return Glib::ustring::compose("%1 %2", data_->Maker, data_->Model); + return Glib::ustring(data_->Maker) + ' ' + data_->Model; } else { return "---"; } From 008f280e2918cce406c270161f825c96b7421eba Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Thu, 14 Sep 2017 11:34:41 +0200 Subject: [PATCH 2/5] lensfun: added possibility to use a private copy of the LF database --- CMakeLists.txt | 4 ++++ rtengine/init.cc | 2 +- rtengine/rtlensfun.cc | 21 +++++++++++++++++++-- rtengine/rtlensfun.h | 2 +- rtengine/settings.h | 3 +++ rtgui/config.h.in | 1 + rtgui/options.cc | 11 +++++++++++ 7 files changed, 40 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 333e292f0..13ba209bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,10 @@ if(NOT DEFINED APPDATADIR) endif() endif() +if(DEFINED LENSFUNDBDIR AND NOT IS_ABSOLUTE "${LENSFUNDBDIR}") + set(LENSFUNDBDIR "${DATADIR}/${LENSFUNDBDIR}") +endif() + # Enforce absolute paths for non-bundle builds: if(NOT BUILD_BUNDLE) foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) diff --git a/rtengine/init.cc b/rtengine/init.cc index 7ef40f43a..7ac4ca35b 100644 --- a/rtengine/init.cc +++ b/rtengine/init.cc @@ -51,7 +51,7 @@ int init (const Settings* s, Glib::ustring baseDir, Glib::ustring userSettingsDi Color::init (); PerceptualToneCurve::init (); RawImageSource::init (); - LFDatabase::init(); + LFDatabase::init(s->lensfunDbDirectory); delete lcmsMutex; lcmsMutex = new MyMutex; dfm.init( s->darkFramesPath ); diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index b42be9424..06c01f975 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -253,10 +253,27 @@ bool LFLens::hasDistortionCorrection() const LFDatabase LFDatabase::instance_; -bool LFDatabase::init() +bool LFDatabase::init(const Glib::ustring &dbdir) { instance_.data_ = lfDatabase::Create(); - return instance_.data_->Load() != LF_NO_ERROR; + + if (settings->verbose) { + std::cout << "Loading lensfun database from "; + if (dbdir.empty()) { + std::cout << "the default directories"; + } else { + std::cout << "'" << dbdir << "'"; + } + std::cout << "..." << std::flush; + } + + bool ok = instance_.data_->Load(dbdir.empty() ? nullptr : dbdir.c_str()) == LF_NO_ERROR; + + if (settings->verbose) { + std::cout << (ok ? "OK" : "FAIL") << std::endl; + } + + return ok; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 5774968ee..a4ff17ae9 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -100,7 +100,7 @@ class LFDatabase final : public NonCopyable { public: - static bool init(); + static bool init(const Glib::ustring &dbdir); static const LFDatabase *getInstance(); ~LFDatabase(); diff --git a/rtengine/settings.h b/rtengine/settings.h index ada63400a..225503777 100644 --- a/rtengine/settings.h +++ b/rtengine/settings.h @@ -92,6 +92,9 @@ public: double ed_low; double ed_lipinfl; double ed_lipampl; + + Glib::ustring lensfunDbDirectory; ///< The directory containing the lensfun database. If empty, the system defaults will be used (as described in http://lensfun.sourceforge.net/manual/dbsearch.html) + /** Creates a new instance of Settings. * @return a pointer to the new Settings instance. */ static Settings* create (); diff --git a/rtgui/config.h.in b/rtgui/config.h.in index cab481278..fdf64b73c 100644 --- a/rtgui/config.h.in +++ b/rtgui/config.h.in @@ -25,5 +25,6 @@ #define DOC_SEARCH_PATH "${DOCDIR}" #define CREDITS_SEARCH_PATH "${CREDITSDIR}" #define LICENCE_SEARCH_PATH "${LICENCEDIR}" +#define LENSFUN_DB_PATH "${LENSFUNDBDIR}" #endif diff --git a/rtgui/options.cc b/rtgui/options.cc index 2b504a2de..c2e2b586b 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -24,6 +24,7 @@ #include "addsetids.h" #include "guiutils.h" #include "version.h" +#include "config.h" #ifdef _OPENMP #include @@ -727,6 +728,8 @@ void Options::setDefaults () lastLensProfileDir = ""; gimpPluginShowInfoDialog = true; maxRecentFolders = 15; + + rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH; } Options* Options::copyFrom (Options* other) @@ -1868,6 +1871,12 @@ void Options::readFromFile (Glib::ustring fname) } } + if (keyFile.has_group ("Lensfun")) { + if (keyFile.has_key ("Lensfun", "DBDirectory")) { + rtSettings.lensfunDbDirectory = keyFile.get_string ("Lensfun", "DBDirectory"); + } + } + // -------------------------------------------------------------------------------------------------------- filterOutParsedExtensions (); @@ -2239,6 +2248,8 @@ void Options::saveToFile (Glib::ustring fname) keyFile.set_string ("Dialogs", "LastLensProfileDir", lastLensProfileDir); keyFile.set_boolean ("Dialogs", "GimpPluginShowInfoDialog", gimpPluginShowInfoDialog); + keyFile.set_string ("Lensfun", "DBDirectory", rtSettings.lensfunDbDirectory); + keyData = keyFile.to_data (); } catch (Glib::KeyFileError &e) { From a515329bac47f968ff3988b888d6eae14713255c Mon Sep 17 00:00:00 2001 From: heckflosse Date: Thu, 14 Sep 2017 13:24:19 +0200 Subject: [PATCH 3/5] Don't pass nullptr to lensfun Load() --- rtengine/rtlensfun.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 06c01f975..32d498589 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -267,7 +267,7 @@ bool LFDatabase::init(const Glib::ustring &dbdir) std::cout << "..." << std::flush; } - bool ok = instance_.data_->Load(dbdir.empty() ? nullptr : dbdir.c_str()) == LF_NO_ERROR; + bool ok = dbdir.empty() ? instance_.data_->Load() : instance_.data_->Load(dbdir.c_str()) == LF_NO_ERROR; if (settings->verbose) { std::cout << (ok ? "OK" : "FAIL") << std::endl; From be2b1ed04395802584dd444dee26b40161c3f715 Mon Sep 17 00:00:00 2001 From: heckflosse Date: Thu, 14 Sep 2017 13:53:03 +0200 Subject: [PATCH 4/5] Use LoadDirectory() instead of Load() when dbdir is not empty --- rtengine/rtlensfun.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 32d498589..a352613ab 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -267,7 +267,7 @@ bool LFDatabase::init(const Glib::ustring &dbdir) std::cout << "..." << std::flush; } - bool ok = dbdir.empty() ? instance_.data_->Load() : instance_.data_->Load(dbdir.c_str()) == LF_NO_ERROR; + bool ok = dbdir.empty() ? (instance_.data_->Load() == LF_NO_ERROR) : instance_.data_->LoadDirectory(dbdir.c_str()); if (settings->verbose) { std::cout << (ok ? "OK" : "FAIL") << std::endl; From 952ada554ae86a3df376a23477b8f616006bb8dd Mon Sep 17 00:00:00 2001 From: heckflosse Date: Thu, 14 Sep 2017 17:13:45 +0200 Subject: [PATCH 5/5] Preview not updating properly when going back in history with LCP vignetting correction, fixes #4073 --- rtgui/paramsedited.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index 7c32265d9..aa3c21256 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -3053,7 +3053,7 @@ bool RAWParamsEdited::isUnchanged() const bool LensProfParamsEdited::isUnchanged() const { - return lcpFile; + return lcpFile && useVign && lfLens; } bool RetinexParamsEdited::isUnchanged() const