lensfun: added possibility to use a private copy of the LF database

This commit is contained in:
Alberto Griggio
2017-09-14 11:34:41 +02:00
parent 5b3d60bf56
commit 008f280e29
7 changed files with 40 additions and 4 deletions

View File

@@ -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)

View File

@@ -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 );

View File

@@ -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;
}

View File

@@ -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();

View File

@@ -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 ();

View File

@@ -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

View File

@@ -24,6 +24,7 @@
#include "addsetids.h"
#include "guiutils.h"
#include "version.h"
#include "config.h"
#ifdef _OPENMP
#include <omp.h>
@@ -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) {