Skip to content
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