Reverted 'GUI: Added CFGDIR qmake flag' there are various installation problems and this only fixes one of them.

This commit is contained in:
Daniel Marjamäki 2013-12-31 10:35:34 +01:00
parent 7e71c41ba7
commit 803182bf45
5 changed files with 31 additions and 73 deletions

View File

@ -145,9 +145,3 @@ win32 {
HEADERS += ../lib/version.h
LIBS += -lshlwapi
}
# CFGDIR=xyz
contains(CFGDIR, .+) {
DEFINES += CFGDIR=\\\"$${CFGDIR}\\\"
}

View File

@ -512,31 +512,6 @@ void MainWindow::AddIncludeDirs(const QStringList &includeDirs, Settings &result
}
}
bool MainWindow::LoadLibrary(Library *library, QString filename)
{
// Try to load the library from the project folder..
if (mProject) {
QString path = QFileInfo(mProject->GetProjectFile()->GetFilename()).canonicalPath();
if (library->load(NULL, (path+"/"+filename).toLatin1()))
return true;
}
if (Library::cfgdir() && library->load(NULL, (Library::cfgdir()+('/'+filename)).toLatin1()))
return true;
// Try to load the library from the application folder..
QString path = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath();
if (library->load(NULL, (path+"/"+filename).toLatin1()))
return true;
// Try to load the library from the cfg subfolder..
path = path + "/cfg";
if (library->load(NULL, (path+"/"+filename).toLatin1()))
return true;
return false;
}
Settings MainWindow::GetCppcheckSettings()
{
Settings result;
@ -558,8 +533,23 @@ Settings MainWindow::GetCppcheckSettings()
QStringList libraries = pfile->GetLibraries();
foreach(QString library, libraries) {
const QString filename = library + ".cfg";
if (!LoadLibrary(&result.library, filename))
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library %1").arg(filename));
// Try to load the library from the project folder..
QString path = QFileInfo(pfile->GetFilename()).canonicalPath();
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
// Try to load the library from the application folder..
path = QFileInfo(QCoreApplication::applicationFilePath()).canonicalPath();
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
// Try to load the library from the cfg subfolder..
path = path + "/cfg";
if (result.library.load("", (path+"/"+filename).toLatin1()))
continue;
QMessageBox::information(this, tr("Information"), tr("Failed to load the selected library %1").arg(filename));
}
QStringList suppressions = pfile->GetSuppressions();
@ -601,10 +591,11 @@ Settings MainWindow::GetCppcheckSettings()
result.standards.c = mSettings->value(SETTINGS_STD_C99, true).toBool() ? Standards::C99 : (mSettings->value(SETTINGS_STD_C11, false).toBool() ? Standards::C11 : Standards::C89);
result.standards.posix = mSettings->value(SETTINGS_STD_POSIX, false).toBool();
bool std = LoadLibrary(&result.library, "std.cfg");
const QString applicationFilePath = QCoreApplication::applicationFilePath();
bool std = result.library.load(applicationFilePath.toLatin1(), "std.cfg");
bool posix = true;
if (result.standards.posix)
posix = LoadLibrary(&result.library, "posix.cfg");
posix = result.library.load(applicationFilePath.toLatin1(), "posix.cfg");
if (!std || !posix)
QMessageBox::warning(this, tr("Error"), tr("Failed to load %1. Your Cppcheck installation is broken.").arg(!std ? "std.cfg" : "posix.cfg"));

View File

@ -424,14 +424,6 @@ private:
*/
void LoadProjectFile(const QString &filePath);
/**
* @brief Load library file
* @param Library library to use
* @param filename filename (no path)
* @return True if successful
*/
bool LoadLibrary(Library *library, QString filename);
/**
* @brief Update project MRU items in File-menu.
*/

View File

@ -46,33 +46,23 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent)
// Checkboxes for the libraries..
const QString applicationFilePath = QCoreApplication::applicationFilePath();
const QString appPath = QFileInfo(applicationFilePath).canonicalPath();
QStringList searchPaths;
if (Library::cfgdir())
searchPaths << Library::cfgdir();
searchPaths << inf.canonicalPath();
searchPaths << appPath;
searchPaths << (appPath + "/cfg");
QStringList libraries;
foreach(const QString path, searchPaths) {
QDir dir(path);
const QString searchPaths[] = { appPath, appPath + "/cfg", inf.canonicalPath() };
for (int i = 0; i < 3; i++) {
QDir dir(searchPaths[i]);
dir.setSorting(QDir::Name);
dir.setNameFilters(QStringList("*.cfg"));
dir.setFilter(QDir::Files | QDir::NoDotAndDotDot);
foreach(QFileInfo item, dir.entryInfoList()) {
libraries << item.fileName();
QString library = item.fileName();
library.chop(4);
if (library.compare("std", Qt::CaseInsensitive) == 0)
continue;
QCheckBox *checkbox = new QCheckBox(this);
checkbox->setText(library);
mUI.librariesLayout->addWidget(checkbox);
mLibraryCheckboxes << checkbox;
}
}
libraries.removeDuplicates();
libraries.sort();
foreach(QString library, libraries) {
library.chop(4);
if (library.compare("std", Qt::CaseInsensitive) == 0)
continue;
QCheckBox *checkbox = new QCheckBox(this);
checkbox->setText(library);
mUI.librariesLayout->addWidget(checkbox);
mLibraryCheckboxes << checkbox;
}
connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept()));
connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir()));

View File

@ -44,15 +44,6 @@ class CPPCHECKLIB Library {
public:
Library();
/** return cfgdir or NULL */
static const char *cfgdir() {
#ifdef CFGDIR
return CFGDIR;
#else
return NULL;
#endif
}
bool load(const char exename [], const char path []);
bool load(const tinyxml2::XMLDocument &doc);