From 6f3d5688d82f3cace89423e364741f01a5d320c7 Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Thu, 19 Oct 2017 16:03:33 +0200 Subject: [PATCH] Fixed bug in finding lensfun lens when maker name consists of multiple words --- rtengine/rtlensfun.cc | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index ddbeca9bf..ed19f44f0 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -393,14 +393,22 @@ LFLens LFDatabase::findLens(const LFCamera &camera, const Glib::ustring &name) c lname = camera.getModel(); // "Standard" } auto found = data_->FindLenses(camera.data_, nullptr, lname.c_str()); - if (!found) { - // try to split the maker from the model of the lens + for (size_t pos = 0; !found && pos < name.size(); ) { + // try to split the maker from the model of the lens -- we have to + // guess a bit here, since there are makers with a multi-word name + // (e.g. "Leica Camera AG") + if (name.find("f/", pos) == 0) { + break; // no need to search further + } Glib::ustring make, model; - auto i = name.find_first_of(' '); + auto i = name.find(' ', pos); if (i != Glib::ustring::npos) { make = name.substr(0, i); model = name.substr(i+1); found = data_->FindLenses(camera.data_, make.c_str(), model.c_str()); + pos = i+1; + } else { + break; } } if (found) {