diff --git a/cli/cppcheckexecutor.cpp b/cli/cppcheckexecutor.cpp index ccfadfdf7..30c94d3ab 100644 --- a/cli/cppcheckexecutor.cpp +++ b/cli/cppcheckexecutor.cpp @@ -151,14 +151,22 @@ int CppCheckExecutor::check(int argc, const char* const argv[]) Settings& settings = cppCheck.settings(); _settings = &settings; - settings.library.load(argv[0], "std"); - if (!parseFromArgs(&cppCheck, argc, argv)) { return EXIT_FAILURE; } + bool std = settings.library.load(argv[0], "std"); + bool posix = true; if (settings.standards.posix) - settings.library.load(argv[0], "posix"); + posix = settings.library.load(argv[0], "posix"); + + if (!std || !posix) { + const std::list callstack; + const std::string msg("Failed to load " + std::string(!std ? "std.cfg" : "posix.cfg") + ". Your Cppcheck installation is broken."); + ErrorLogger::ErrorMessage errmsg(callstack, Severity::information, msg, "failedToLoadCfg", false); + reportErr(errmsg); + return EXIT_FAILURE; + } if (settings.reportProgress) time1 = std::time(0); diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 70b0d6374..a62d39be5 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -565,9 +565,13 @@ Settings MainWindow::GetCppcheckSettings() result.standards.posix = mSettings->value(SETTINGS_STD_POSIX, false).toBool(); const QString applicationFilePath = QCoreApplication::applicationFilePath(); - result.library.load(applicationFilePath.toLatin1(), "std"); + bool std = result.library.load(applicationFilePath.toLatin1(), "std"); + bool posix = true; if (result.standards.posix) - result.library.load(applicationFilePath.toLatin1(), "posix"); + posix = result.library.load(applicationFilePath.toLatin1(), "posix"); + + if (!std || !posix) + QMessageBox::warning(this, "Error", "Failed to load " + QString(!std ? "std.cfg" : "posix.cfg") + ". Your Cppcheck installation is broken."); if (result._jobs <= 1) { result._jobs = 1;