Skip to content

Commit

Permalink
fixes #12752 - added missing path seperator in GUI library lookup / u…
Browse files Browse the repository at this point in the history
…se `qDebug()` for GUI library loading logging (#6529)
  • Loading branch information
firewave committed Jun 15, 2024
1 parent 3c772a4 commit 27f155c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
28 changes: 10 additions & 18 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,16 +836,15 @@ void MainWindow::addIncludeDirs(const QStringList &includeDirs, Settings &result
}
}

Library::Error MainWindow::loadLibrary(Library &library, const QString &filename, bool debug)
Library::Error MainWindow::loadLibrary(Library &library, const QString &filename)
{
Library::Error ret;

// Try to load the library from the project folder..
if (mProjectFile) {
QString path = QFileInfo(mProjectFile->getFilename()).canonicalPath();
QString libpath = path+"/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
Expand All @@ -854,14 +853,12 @@ Library::Error MainWindow::loadLibrary(Library &library, const QString &filename
// Try to load the library from the application folder..
const QString appPath = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath();
QString libpath = appPath+"/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
libpath = appPath+"/cfg/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
Expand All @@ -871,14 +868,12 @@ Library::Error MainWindow::loadLibrary(Library &library, const QString &filename
const QString filesdir = FILESDIR;
if (!filesdir.isEmpty()) {
libpath = filesdir+"/cfg/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
libpath = filesdir+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
libpath = filesdir+"/"+filename;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
Expand All @@ -889,21 +884,18 @@ Library::Error MainWindow::loadLibrary(Library &library, const QString &filename
const QString datadir = getDataDir();
if (!datadir.isEmpty()) {
libpath = datadir+"/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
libpath = datadir+"/cfg/"+filename;
if (debug)
std::cout << "looking for library '" + libpath.toStdString() + "'" << std::endl;
qDebug().noquote() << "looking for library '" + libpath + "'";
ret = library.load(nullptr, libpath.toLatin1());
if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND)
return ret;
}

if (debug)
std::cout << "library not found: '" + filename.toStdString() + "'" << std::endl;
qDebug().noquote() << "library not found: '" + filename + "'";

return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private slots:
* @param filename filename (no path)
* @return error code
*/
Library::Error loadLibrary(Library &library, const QString &filename, bool debug = false);
Library::Error loadLibrary(Library &library, const QString &filename);

/**
* @brief Tries to load library file, prints message on error
Expand Down

0 comments on commit 27f155c

Please sign in to comment.