From 4131c621c99efe2b2d2bbe43f530e3bf1bbd6105 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 26 Dec 2013 11:15:28 +0100 Subject: [PATCH] Fixed #5254 (Warn about missing library files (.cfg)) --- cli/cppcheckexecutor.cpp | 14 +++++++++++--- gui/mainwindow.cpp | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) 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;