Skip to content

Commit 803182b

Browse files
committed
Reverted 'GUI: Added CFGDIR qmake flag' there are various installation problems and this only fixes one of them.
1 parent 7e71c41 commit 803182b

5 files changed

Lines changed: 31 additions & 73 deletions

File tree

gui/gui.pro

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,3 @@ win32 {
145145
HEADERS += ../lib/version.h
146146
LIBS += -lshlwapi
147147
}
148-
149-
150-
# CFGDIR=xyz
151-
contains(CFGDIR, .+) {
152-
DEFINES += CFGDIR=\\\"$${CFGDIR}\\\"
153-
}

gui/mainwindow.cpp

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
540515
Settings 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"));

gui/mainwindow.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,6 @@ protected slots:
424424
*/
425425
void LoadProjectFile(const QString &filePath);
426426

427-
/**
428-
* @brief Load library file
429-
* @param Library library to use
430-
* @param filename filename (no path)
431-
* @return True if successful
432-
*/
433-
bool LoadLibrary(Library *library, QString filename);
434-
435427
/**
436428
* @brief Update project MRU items in File-menu.
437429
*/

gui/projectfiledialog.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,23 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
4646
// Checkboxes for the libraries..
4747
const QString applicationFilePath = QCoreApplication::applicationFilePath();
4848
const QString appPath = QFileInfo(applicationFilePath).canonicalPath();
49-
QStringList searchPaths;
50-
if (Library::cfgdir())
51-
searchPaths << Library::cfgdir();
52-
searchPaths << inf.canonicalPath();
53-
searchPaths << appPath;
54-
searchPaths << (appPath + "/cfg");
55-
QStringList libraries;
56-
foreach(const QString path, searchPaths) {
57-
QDir dir(path);
49+
const QString searchPaths[] = { appPath, appPath + "/cfg", inf.canonicalPath() };
50+
for (int i = 0; i < 3; i++) {
51+
QDir dir(searchPaths[i]);
5852
dir.setSorting(QDir::Name);
5953
dir.setNameFilters(QStringList("*.cfg"));
6054
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
6155
foreach(QFileInfo item, dir.entryInfoList()) {
62-
libraries << item.fileName();
56+
QString library = item.fileName();
57+
library.chop(4);
58+
if (library.compare("std", Qt::CaseInsensitive) == 0)
59+
continue;
60+
QCheckBox *checkbox = new QCheckBox(this);
61+
checkbox->setText(library);
62+
mUI.librariesLayout->addWidget(checkbox);
63+
mLibraryCheckboxes << checkbox;
6364
}
6465
}
65-
libraries.removeDuplicates();
66-
libraries.sort();
67-
foreach(QString library, libraries) {
68-
library.chop(4);
69-
if (library.compare("std", Qt::CaseInsensitive) == 0)
70-
continue;
71-
QCheckBox *checkbox = new QCheckBox(this);
72-
checkbox->setText(library);
73-
mUI.librariesLayout->addWidget(checkbox);
74-
mLibraryCheckboxes << checkbox;
75-
}
7666

7767
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
7868
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));

lib/library.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ class CPPCHECKLIB Library {
4444
public:
4545
Library();
4646

47-
/** return cfgdir or NULL */
48-
static const char *cfgdir() {
49-
#ifdef CFGDIR
50-
return CFGDIR;
51-
#else
52-
return NULL;
53-
#endif
54-
}
55-
5647
bool load(const char exename [], const char path []);
5748
bool load(const tinyxml2::XMLDocument &doc);
5849

0 commit comments

Comments
 (0)