GUI: Load user-selected library properly

This commit is contained in:
Daniel Marjamäki 2013-12-30 00:23:42 +01:00
parent bf8bb29938
commit ac91aa4fdf
1 changed files with 18 additions and 3 deletions

View File

@ -532,9 +532,24 @@ Settings MainWindow::GetCppcheckSettings()
QStringList libraries = pfile->GetLibraries();
foreach(QString library, libraries) {
const QString applicationFilePath = QCoreApplication::applicationFilePath();
if (!result.library.load(applicationFilePath.toLatin1(), (library+".cfg").toLatin1()))
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library %1").arg(library));
const QString filename = library + ".cfg";
// Try to load the library from the project folder..
QString path = QFileInfo(pfile->GetFilename()).canonicalPath();
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
// Try to load the library from the application folder..
path = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath();
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
// Try to load the library from the cfg subfolder..
path = path + "/cfg";
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library %1").arg(filename));
}
// Only check the given -D configuration