Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #12752 - added missing path seperator in GUI library lookup / use qDebug() for GUI library loading logging #6529

Merged
merged 2 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading