From a7529302e1266daddf066f18e123580b3d8ec6f0 Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 29 Oct 2014 18:42:46 -0400 Subject: [PATCH] give precedence to loading local/relative files --- openbr/core/core.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 9233aad..45f6d41 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -513,15 +513,15 @@ private: // Check if description is either an abbreviation or a model file, if so load it bool loadOrExpand(const QString &description) { - // Check if a trained binary already exists for this algorithm - QString file = Globals->sdkPath + "/share/openbr/models/algorithms/" + description; - QFileInfo eFile(file); - file = eFile.exists() && !eFile.isDir() ? file : description; - - QFileInfo dFile(file); - if (dFile.exists() && !dFile.isDir()) { - qDebug("Loading %s", qPrintable(dFile.canonicalFilePath())); - load(file); + // Check if a trained binary already exists for this algorithm, + // giving priority to local files before defaulting to openbr/share/models/algorithms. + QFileInfo fileInfo(description); + if (!fileInfo.exists() || fileInfo.isDir()) + fileInfo = QFileInfo(Globals->sdkPath + "/share/openbr/models/algorithms/" + description); + if (fileInfo.exists() && !fileInfo.isDir()) { + const QString filePath = fileInfo.canonicalFilePath(); + qDebug("Loading %s", qPrintable(filePath)); + load(filePath); return true; } -- libgit2 0.21.4