Skip to content

Commit

Permalink
Allow relative CLUT paths (#3639) by @agriggio
Browse files Browse the repository at this point in the history
Kudos to Alberto Griggio for this contribution! 👍
  • Loading branch information
Floessie committed Feb 14, 2017
1 parent 6b6c080 commit 6bcac40
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
11 changes: 8 additions & 3 deletions rtengine/clutstore.cc
Expand Up @@ -307,12 +307,17 @@ std::shared_ptr<rtengine::HaldCLUT> rtengine::CLUTStore::getClut(const Glib::ust
{
std::shared_ptr<rtengine::HaldCLUT> result;

if (!cache.get(filename, result)) {
Glib::ustring full_filename = filename;
if ( !Glib::path_is_absolute(full_filename) ) {
full_filename = Glib::build_filename(options.clutsDir, filename);
}

if (!cache.get(full_filename, result)) {
std::unique_ptr<rtengine::HaldCLUT> clut(new rtengine::HaldCLUT);

if (clut->load(filename)) {
if (clut->load(full_filename)) {
result = std::move(clut);
cache.insert(filename, result);
cache.insert(full_filename, result);
}
}

Expand Down
22 changes: 20 additions & 2 deletions rtgui/filmsimulation.cc
Expand Up @@ -11,6 +11,18 @@ using namespace rtengine::procparams;
namespace
{

Glib::ustring stripPrefixDir(const Glib::ustring &filename,
Glib::ustring dir)
{
if (!Glib::str_has_suffix(dir, G_DIR_SEPARATOR_S)) {
dir += G_DIR_SEPARATOR_S;
}
if (Glib::str_has_prefix(filename, dir)) {
return filename.substr(dir.size());
}
return filename;
}

bool notifySlowParseDir (const std::chrono::system_clock::time_point& startedAt)
{
static enum
Expand Down Expand Up @@ -116,7 +128,12 @@ void FilmSimulation::read( const rtengine::procparams::ProcParams* pp, const Par
setEnabled (pp->filmSimulation.enabled);

if ( !pp->filmSimulation.clutFilename.empty() ) {
m_clutComboBox->setSelectedClut( pp->filmSimulation.clutFilename );
Glib::ustring full_filename(pp->filmSimulation.clutFilename);
if ( !Glib::path_is_absolute(full_filename) ) {
full_filename = Glib::build_filename(options.clutsDir,
full_filename);
}
m_clutComboBox->setSelectedClut( full_filename );
}

m_strength->setValue( pp->filmSimulation.strength );
Expand Down Expand Up @@ -157,7 +174,8 @@ void FilmSimulation::write( rtengine::procparams::ProcParams* pp, ParamsEdited*
Glib::ustring clutFName = m_clutComboBox->getSelectedClut();

if ( clutFName != "NULL" ) { // We do not want to set "NULL" in clutFilename, even if "unedited"
pp->filmSimulation.clutFilename = clutFName;
pp->filmSimulation.clutFilename = stripPrefixDir(clutFName,
options.clutsDir);
}

pp->filmSimulation.strength = m_strength->getValue();
Expand Down

0 comments on commit 6bcac40

Please sign in to comment.