GUI: Disable addons that are not found
This commit is contained in:
parent
2a6f63d995
commit
74fc6485d2
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
@ -74,13 +75,11 @@ void CheckThread::run()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString addonPath = getAddonPath();
|
|
||||||
|
|
||||||
QString file = mResult.getNextFile();
|
QString file = mResult.getNextFile();
|
||||||
while (!file.isEmpty() && mState == Running) {
|
while (!file.isEmpty() && mState == Running) {
|
||||||
qDebug() << "Checking file" << file;
|
qDebug() << "Checking file" << file;
|
||||||
mCppcheck.check(file.toStdString());
|
mCppcheck.check(file.toStdString());
|
||||||
runAddonsAndTools(addonPath, nullptr, file);
|
runAddonsAndTools(nullptr, file);
|
||||||
emit fileChecked(file);
|
emit fileChecked(file);
|
||||||
|
|
||||||
if (mState == Running)
|
if (mState == Running)
|
||||||
|
@ -92,7 +91,7 @@ void CheckThread::run()
|
||||||
file = QString::fromStdString(fileSettings.filename);
|
file = QString::fromStdString(fileSettings.filename);
|
||||||
qDebug() << "Checking file" << file;
|
qDebug() << "Checking file" << file;
|
||||||
mCppcheck.check(fileSettings);
|
mCppcheck.check(fileSettings);
|
||||||
runAddonsAndTools(addonPath, &fileSettings, QString::fromStdString(fileSettings.filename));
|
runAddonsAndTools(&fileSettings, QString::fromStdString(fileSettings.filename));
|
||||||
emit fileChecked(file);
|
emit fileChecked(file);
|
||||||
|
|
||||||
if (mState == Running)
|
if (mState == Running)
|
||||||
|
@ -107,7 +106,7 @@ void CheckThread::run()
|
||||||
emit done();
|
emit done();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckThread::runAddonsAndTools(const QString &addonPath, const ImportProject::FileSettings *fileSettings, const QString &fileName)
|
void CheckThread::runAddonsAndTools(const ImportProject::FileSettings *fileSettings, const QString &fileName)
|
||||||
{
|
{
|
||||||
QString dumpFile;
|
QString dumpFile;
|
||||||
|
|
||||||
|
@ -263,13 +262,12 @@ void CheckThread::runAddonsAndTools(const QString &addonPath, const ImportProjec
|
||||||
|
|
||||||
parseClangErrors(addon, fileName, errout);
|
parseClangErrors(addon, fileName, errout);
|
||||||
} else {
|
} else {
|
||||||
QString a;
|
QString a = CheckThread::getAddonFilePath(mDataDir, addon + ".py");
|
||||||
if (QFileInfo(addonPath + '/' + addon + ".py").exists())
|
if (a.isEmpty()) {
|
||||||
a = addonPath + '/' + addon + ".py";
|
a = CheckThread::getAddonFilePath(QApplication::applicationDirPath(), addon + ".py");
|
||||||
else if (QFileInfo(addonPath + '/' + addon + '/' + addon + ".py").exists())
|
if (a.isEmpty())
|
||||||
a = addonPath + '/' + addon + '/' + addon + ".py";
|
continue;
|
||||||
else
|
}
|
||||||
continue;
|
|
||||||
|
|
||||||
if (dumpFile.isEmpty()) {
|
if (dumpFile.isEmpty()) {
|
||||||
const std::string buildDir = mCppcheck.settings().buildDir;
|
const std::string buildDir = mCppcheck.settings().buildDir;
|
||||||
|
@ -321,21 +319,6 @@ void CheckThread::stop()
|
||||||
mCppcheck.terminate();
|
mCppcheck.terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CheckThread::getAddonPath() const
|
|
||||||
{
|
|
||||||
if (QFileInfo(mDataDir + "/threadsafety.py").exists())
|
|
||||||
return mDataDir;
|
|
||||||
else if (QDir(mDataDir + "/addons").exists())
|
|
||||||
return mDataDir + "/addons";
|
|
||||||
else if (QDir(mDataDir + "/../addons").exists())
|
|
||||||
return mDataDir + "/../addons";
|
|
||||||
else if (mDataDir.endsWith("/cfg")) {
|
|
||||||
if (QDir(mDataDir.mid(0,mDataDir.size()-3) + "addons").exists())
|
|
||||||
return mDataDir.mid(0,mDataDir.size()-3) + "addons";
|
|
||||||
}
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckThread::parseAddonErrors(QString err, QString tool)
|
void CheckThread::parseAddonErrors(QString err, QString tool)
|
||||||
{
|
{
|
||||||
Q_UNUSED(tool);
|
Q_UNUSED(tool);
|
||||||
|
@ -447,3 +430,16 @@ void CheckThread::parseClangErrors(const QString &tool, const QString &file0, QS
|
||||||
mResult.reportErr(errmsg);
|
mResult.reportErr(errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CheckThread::getAddonFilePath(const QString &dataDir, const QString &addonFile)
|
||||||
|
{
|
||||||
|
if (dataDir.isEmpty())
|
||||||
|
return QString();
|
||||||
|
if (QFileInfo(dataDir + '/' + addonFile).exists())
|
||||||
|
return dataDir + '/' + addonFile;
|
||||||
|
if (QFileInfo(dataDir + "/addons/" + addonFile).exists())
|
||||||
|
return dataDir + "/addons/" + addonFile;
|
||||||
|
if (QFileInfo(dataDir + "/../addons/" + addonFile).exists())
|
||||||
|
return dataDir + "/../addons/" + addonFile;
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
|
static QString getAddonFilePath(const QString &dataDir, const QString &addonFile);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -122,9 +123,7 @@ protected:
|
||||||
CppCheck mCppcheck;
|
CppCheck mCppcheck;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getAddonPath() const;
|
void runAddonsAndTools(const ImportProject::FileSettings *fileSettings, const QString &fileName);
|
||||||
|
|
||||||
void runAddonsAndTools(const QString &addonPath, const ImportProject::FileSettings *fileSettings, const QString &fileName);
|
|
||||||
|
|
||||||
void parseAddonErrors(QString err, QString tool);
|
void parseAddonErrors(QString err, QString tool);
|
||||||
void parseClangErrors(const QString &tool, const QString &file0, QString err);
|
void parseClangErrors(const QString &tool, const QString &file0, QString err);
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "projectfiledialog.h"
|
#include "projectfiledialog.h"
|
||||||
|
#include "checkthread.h"
|
||||||
#include "projectfile.h"
|
#include "projectfile.h"
|
||||||
#include "library.h"
|
#include "library.h"
|
||||||
#include "cppcheck.h"
|
#include "cppcheck.h"
|
||||||
|
@ -160,6 +161,16 @@ void ProjectFileDialog::saveSettings() const
|
||||||
settings.setValue(SETTINGS_PROJECT_DIALOG_HEIGHT, size().height());
|
settings.setValue(SETTINGS_PROJECT_DIALOG_HEIGHT, size().height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void updateAddonCheckBox(QCheckBox *cb, const ProjectFile *projectFile, const QString &dataDir, const QString &addon)
|
||||||
|
{
|
||||||
|
cb->setChecked(projectFile->getAddons().contains(addon));
|
||||||
|
const QString appPath = QApplication::applicationDirPath();
|
||||||
|
if (CheckThread::getAddonFilePath(dataDir, addon + ".py").isEmpty() && CheckThread::getAddonFilePath(appPath, addon + ".py").isEmpty()) {
|
||||||
|
cb->setEnabled(false);
|
||||||
|
cb->setText(cb->text() + QObject::tr(" (Not found)"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
||||||
{
|
{
|
||||||
setRootPath(projectFile->getRootPath());
|
setRootPath(projectFile->getRootPath());
|
||||||
|
@ -172,7 +183,13 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
|
||||||
setExcludedPaths(projectFile->getExcludedPaths());
|
setExcludedPaths(projectFile->getExcludedPaths());
|
||||||
setLibraries(projectFile->getLibraries());
|
setLibraries(projectFile->getLibraries());
|
||||||
setSuppressions(projectFile->getSuppressions());
|
setSuppressions(projectFile->getSuppressions());
|
||||||
mUI.mAddonThreadSafety->setChecked(projectFile->getAddons().contains("threadsafety"));
|
|
||||||
|
QSettings settings;
|
||||||
|
const QString dataDir = settings.value("DATADIR", QString()).toString();
|
||||||
|
updateAddonCheckBox(mUI.mAddonThreadSafety, projectFile, dataDir, "threadsafety");
|
||||||
|
updateAddonCheckBox(mUI.mAddonY2038, projectFile, dataDir, "y2038");
|
||||||
|
updateAddonCheckBox(mUI.mAddonCert, projectFile, dataDir, "cert");
|
||||||
|
|
||||||
mUI.mAddonY2038->setChecked(projectFile->getAddons().contains("y2038"));
|
mUI.mAddonY2038->setChecked(projectFile->getAddons().contains("y2038"));
|
||||||
mUI.mAddonCert->setChecked(projectFile->getAddons().contains("cert"));
|
mUI.mAddonCert->setChecked(projectFile->getAddons().contains("cert"));
|
||||||
mUI.mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer());
|
mUI.mToolClangAnalyzer->setChecked(projectFile->getClangAnalyzer());
|
||||||
|
|
Loading…
Reference in New Issue