Commit a7529302e1266daddf066f18e123580b3d8ec6f0

Authored by Josh Klontz
1 parent ece1468e

give precedence to loading local/relative files

Showing 1 changed file with 9 additions and 9 deletions
openbr/core/core.cpp
@@ -513,15 +513,15 @@ private: @@ -513,15 +513,15 @@ private:
513 // Check if description is either an abbreviation or a model file, if so load it 513 // Check if description is either an abbreviation or a model file, if so load it
514 bool loadOrExpand(const QString &description) 514 bool loadOrExpand(const QString &description)
515 { 515 {
516 - // Check if a trained binary already exists for this algorithm  
517 - QString file = Globals->sdkPath + "/share/openbr/models/algorithms/" + description;  
518 - QFileInfo eFile(file);  
519 - file = eFile.exists() && !eFile.isDir() ? file : description;  
520 -  
521 - QFileInfo dFile(file);  
522 - if (dFile.exists() && !dFile.isDir()) {  
523 - qDebug("Loading %s", qPrintable(dFile.canonicalFilePath()));  
524 - load(file); 516 + // Check if a trained binary already exists for this algorithm,
  517 + // giving priority to local files before defaulting to openbr/share/models/algorithms.
  518 + QFileInfo fileInfo(description);
  519 + if (!fileInfo.exists() || fileInfo.isDir())
  520 + fileInfo = QFileInfo(Globals->sdkPath + "/share/openbr/models/algorithms/" + description);
  521 + if (fileInfo.exists() && !fileInfo.isDir()) {
  522 + const QString filePath = fileInfo.canonicalFilePath();
  523 + qDebug("Loading %s", qPrintable(filePath));
  524 + load(filePath);
525 return true; 525 return true;
526 } 526 }
527 527