@@ -512,31 +512,6 @@ void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result
512512 }
513513}
514514
515- bool MainWindow::LoadLibrary (Library *library, QString filename)
516- {
517- // Try to load the library from the project folder..
518- if (mProject ) {
519- QString path = QFileInfo (mProject ->GetProjectFile ()->GetFilename ()).canonicalPath ();
520- if (library->load (NULL , (path+" /" +filename).toLatin1 ()))
521- return true ;
522- }
523-
524- if (Library::cfgdir () && library->load (NULL , (Library::cfgdir ()+(' /' +filename)).toLatin1 ()))
525- return true ;
526-
527- // Try to load the library from the application folder..
528- QString path = QFileInfo (QCoreApplication::applicationFilePath ()).canonicalPath ();
529- if (library->load (NULL , (path+" /" +filename).toLatin1 ()))
530- return true ;
531-
532- // Try to load the library from the cfg subfolder..
533- path = path + " /cfg" ;
534- if (library->load (NULL , (path+" /" +filename).toLatin1 ()))
535- return true ;
536-
537- return false ;
538- }
539-
540515Settings MainWindow::GetCppcheckSettings ()
541516{
542517 Settings result;
@@ -558,8 +533,23 @@ Settings MainWindow::GetCppcheckSettings()
558533 QStringList libraries = pfile->GetLibraries ();
559534 foreach (QString library, libraries) {
560535 const QString filename = library + " .cfg" ;
561- if (!LoadLibrary (&result.library , filename))
562- QMessageBox::information (this , tr (" Information" ), tr (" Failed to load the selected library %1" ).arg (filename));
536+
537+ // Try to load the library from the project folder..
538+ QString path = QFileInfo (pfile->GetFilename ()).canonicalPath ();
539+ if (result.library .load (" " , (path+" /" +filename).toLatin1 ()))
540+ continue ;
541+
542+ // Try to load the library from the application folder..
543+ path = QFileInfo (QCoreApplication::applicationFilePath ()).canonicalPath ();
544+ if (result.library .load (" " , (path+" /" +filename).toLatin1 ()))
545+ continue ;
546+
547+ // Try to load the library from the cfg subfolder..
548+ path = path + " /cfg" ;
549+ if (result.library .load (" " , (path+" /" +filename).toLatin1 ()))
550+ continue ;
551+
552+ QMessageBox::information (this , tr (" Information" ), tr (" Failed to load the selected library %1" ).arg (filename));
563553 }
564554
565555 QStringList suppressions = pfile->GetSuppressions ();
@@ -601,10 +591,11 @@ Settings MainWindow::GetCppcheckSettings()
601591 result.standards .c = mSettings ->value (SETTINGS_STD_C99, true ).toBool () ? Standards::C99 : (mSettings ->value (SETTINGS_STD_C11, false ).toBool () ? Standards::C11 : Standards::C89);
602592 result.standards .posix = mSettings ->value (SETTINGS_STD_POSIX, false ).toBool ();
603593
604- bool std = LoadLibrary (&result.library , " std.cfg" );
594+ const QString applicationFilePath = QCoreApplication::applicationFilePath ();
595+ bool std = result.library .load (applicationFilePath.toLatin1 (), " std.cfg" );
605596 bool posix = true ;
606597 if (result.standards .posix )
607- posix = LoadLibrary (& result.library , " posix.cfg" );
598+ posix = result.library . load (applicationFilePath. toLatin1 () , " posix.cfg" );
608599
609600 if (!std || !posix)
610601 QMessageBox::warning (this , tr (" Error" ), tr (" Failed to load %1. Your Cppcheck installation is broken." ).arg (!std ? " std.cfg" : " posix.cfg" ));
0 commit comments