From 310226bb6b2b94495fe2edce5b03952c50da5eae Mon Sep 17 00:00:00 2001 From: David Korth Date: Sat, 15 Oct 2016 19:08:04 -0400 Subject: [PATCH] gui: Check CFGDIR if it's defined. For quite a while, cppcheck-gui hasn't shown any of the standard library packages on my Gentoo system. It turns out that cppcheck-gui doesn't use CFGDIR, but it does use a DATADIR variable stored in QSettings. Problem is, DATADIR isn't set unless you manually specify --data-dir, which isn't very intuitive. This commit adds CFGDIR to the default list of cfg paths if the CFGDIR macro is defined during the build. --- gui/mainwindow.cpp | 13 +++++++++++++ gui/projectfiledialog.cpp | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index affc05186..165f44eec 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -657,6 +657,19 @@ Library::Error MainWindow::LoadLibrary(Library *library, QString filename) if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND) return ret; +#ifdef CFGDIR + // Try to load the library from CFGDIR.. + const QString cfgdir = CFGDIR; + if (!cfgdir.isEmpty()) { + ret = library->load(NULL, (cfgdir+"/"+filename).toLatin1()); + if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND) + return ret; + ret = library->load(NULL, (cfgdir+"/cfg/"+filename).toLatin1()); + if (ret.errorcode != Library::ErrorCode::FILE_NOT_FOUND) + return ret; + } +#endif + // Try to load the library from the cfg subfolder.. const QString datadir = mSettings->value("DATADIR", QString()).toString(); if (!datadir.isEmpty()) { diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index b0ef5f637..1fc0531ae 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -48,9 +48,16 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent) const QString applicationFilePath = QCoreApplication::applicationFilePath(); const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); QSettings settings; +#ifdef CFGDIR + const QString cfgdir = CFGDIR; +#endif const QString datadir = settings.value("DATADIR",QString()).toString(); QStringList searchPaths; searchPaths << appPath << appPath + "/cfg" << inf.canonicalPath(); +#ifdef CFGDIR + if (!cfgdir.isEmpty()) + searchPaths << cfgdir << cfgdir + "/cfg"; +#endif if (!datadir.isEmpty()) searchPaths << datadir << datadir + "/cfg"; QStringList libs;