Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .selfcheck_suppressions
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ funcArgNamesDifferent:*/moc_resultsview.cpp
funcArgNamesDifferent:*/moc_threadhandler.cpp
funcArgNamesDifferent:*/moc_threadresult.cpp
naming-varname:*/gui/ui_*.h
functionStatic:*/ui_fileview.h
functionStatic:*/gui/ui_*.h

# --debug-warnings suppressions
valueFlowBailout
Expand Down
23 changes: 18 additions & 5 deletions gui/checkthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ int CheckThread::executeCommand(std::string exe, std::vector<std::string> args,
}


CheckThread::CheckThread(ThreadResult &result) :
mResult(result)
CheckThread::CheckThread(ThreadResult &result, int threadIndex)
: mResult(result)
, mThreadIndex(threadIndex)
{}

void CheckThread::setSettings(const Settings &settings, std::shared_ptr<Suppressions> supprs)
Expand Down Expand Up @@ -147,9 +148,14 @@ void CheckThread::run()
while (file && mState == Running) {
const std::string& fname = file->spath();
qDebug() << "Checking file" << QString::fromStdString(fname);

const Details details{ mThreadIndex, QString::fromStdString(fname), QTime::currentTime(), };
emit startCheck(details);

cppcheck.check(*file);
runAddonsAndTools(mSettings, nullptr, QString::fromStdString(fname));
emit fileChecked(QString::fromStdString(fname));

emit finishCheck(details);

if (mState == Running)
mResult.getNextFile(file);
Expand All @@ -160,9 +166,15 @@ void CheckThread::run()
while (fileSettings && mState == Running) {
const std::string& fname = fileSettings->filename();
qDebug() << "Checking file" << QString::fromStdString(fname);
cppcheck.check(*fileSettings);

const Details details{ mThreadIndex, QString::fromStdString(fname), QTime::currentTime(), };
emit startCheck(details);

cppcheck.check(*file);
runAddonsAndTools(mSettings, fileSettings, QString::fromStdString(fname));
emit fileChecked(QString::fromStdString(fname));

emit finishCheck(details);


if (mState == Running)
mResult.getNextFileSettings(fileSettings);
Expand Down Expand Up @@ -486,3 +498,4 @@ QString CheckThread::clangTidyCmd()

return QString();
}

16 changes: 13 additions & 3 deletions gui/checkthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <QString>
#include <QStringList>
#include <QThread>
#include <QTime>

class ThreadResult;

Expand All @@ -49,7 +50,14 @@ class ThreadResult;
class CheckThread : public QThread {
Q_OBJECT
public:
explicit CheckThread(ThreadResult &result);
struct Details {
int threadIndex;
QString file;
QTime startTime;
};

public:
CheckThread(ThreadResult &result, int threadIndex);

/**
* @brief Set settings for cppcheck
Expand Down Expand Up @@ -102,8 +110,8 @@ class CheckThread : public QThread {
*/
void done();

// NOLINTNEXTLINE(readability-inconsistent-declaration-parameter-name) - caused by generated MOC code
void fileChecked(const QString &file);
void startCheck(CheckThread::Details details);
void finishCheck(CheckThread::Details details);
protected:

/**
Expand All @@ -126,6 +134,7 @@ class CheckThread : public QThread {
std::atomic<State> mState{Ready};

ThreadResult &mResult;
int mThreadIndex{};

Settings mSettings;
std::shared_ptr<Suppressions> mSuppressions;
Expand All @@ -150,5 +159,6 @@ class CheckThread : public QThread {
QStringList mClangIncludePaths;
QList<SuppressionList::Suppression> mSuppressionsUi;
};
Q_DECLARE_METATYPE(CheckThread::Details);
/// @}
#endif // CHECKTHREAD_H
5 changes: 4 additions & 1 deletion gui/gui.pro
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ FORMS = about.ui \
librarydialog.ui \
libraryaddfunctiondialog.ui \
libraryeditargdialog.ui \
newsuppressiondialog.ui
newsuppressiondialog.ui \
threaddetails.ui

TRANSLATIONS = cppcheck_de.ts \
cppcheck_es.ts \
Expand Down Expand Up @@ -156,6 +157,7 @@ HEADERS += aboutdialog.h \
settingsdialog.h \
showtypes.h \
statsdialog.h \
threaddetails.h \
threadhandler.h \
threadresult.h \
translationhandler.h \
Expand Down Expand Up @@ -199,6 +201,7 @@ SOURCES += aboutdialog.cpp \
settingsdialog.cpp \
showtypes.cpp \
statsdialog.cpp \
threaddetails.cpp \
threadhandler.cpp \
threadresult.cpp \
translationhandler.cpp \
Expand Down
17 changes: 17 additions & 0 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "threadresult.h"
#include "translationhandler.h"
#include "utils.h"
#include "threaddetails.h"

#include "ui_mainwindow.h"

Expand Down Expand Up @@ -183,6 +184,7 @@ MainWindow::MainWindow(TranslationHandler* th, QSettings* settings) :
connect(mUI->mActionShowHidden, &QAction::triggered, mUI->mResults, &ResultsView::showHiddenResults);
connect(mUI->mActionViewStats, &QAction::triggered, this, &MainWindow::showStatistics);
connect(mUI->mActionLibraryEditor, &QAction::triggered, this, &MainWindow::showLibraryEditor);
connect(mUI->mActionShowThreadDetails, &QAction::triggered, this, &MainWindow::showThreadDetails);

connect(mUI->mActionReanalyzeModified, &QAction::triggered, this, &MainWindow::reAnalyzeModified);
connect(mUI->mActionReanalyzeAll, &QAction::triggered, this, &MainWindow::reAnalyzeAll);
Expand Down Expand Up @@ -1069,6 +1071,7 @@ bool MainWindow::getCppcheckSettings(Settings& settings, Suppressions& supprs)

settings.exename = QCoreApplication::applicationFilePath().toStdString();
settings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]";
settings.reportProgress = 10;

// default to --check-level=normal for GUI for now
settings.setCheckLevel(Settings::CheckLevel::normal);
Expand Down Expand Up @@ -2109,6 +2112,20 @@ void MainWindow::showLibraryEditor()
libraryDialog.exec();
}

void MainWindow::showThreadDetails()
{
if (ThreadDetails::instance())
return;
auto* threadDetails = new ThreadDetails(this);
connect(mThread, &ThreadHandler::threadDetailsUpdated,
threadDetails, &ThreadDetails::threadDetailsUpdated, Qt::QueuedConnection);
connect(mThread, &ThreadHandler::progress,
threadDetails, &ThreadDetails::progress, Qt::QueuedConnection);
threadDetails->setAttribute(Qt::WA_DeleteOnClose);
threadDetails->show();
mThread->emitThreadDetailsUpdated();
}

void MainWindow::filterResults()
{
mUI->mResults->filterResults(mLineEditFilter->text());
Expand Down
3 changes: 3 additions & 0 deletions gui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ public slots:
/** @brief Slot for showing the library editor */
void showLibraryEditor();

/** @brief Slot for showing the thread details window */
void showThreadDetails();

private slots:

/** @brief Slot for checkthread's done signal */
Expand Down
19 changes: 14 additions & 5 deletions gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<item>
<layout class="QHBoxLayout" name="mLayoutInformation">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
<enum>QLayout::SizeConstraint::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="mLabelInformation">
Expand All @@ -84,13 +84,13 @@
<string>Checking for updates</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
<enum>Qt::TextFormat::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
<set>Qt::TextInteractionFlag::TextBrowserInteraction</set>
</property>
</widget>
</item>
Expand All @@ -104,7 +104,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -124,7 +124,7 @@
<x>0</x>
<y>0</y>
<width>640</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="mMenuFile">
Expand Down Expand Up @@ -192,6 +192,7 @@
<addaction name="mActionShowScratchpad"/>
<addaction name="mActionViewStats"/>
<addaction name="mActionLibraryEditor"/>
<addaction name="mActionShowThreadDetails"/>
</widget>
<widget class="QMenu" name="mMenuHelp">
<property name="title">
Expand Down Expand Up @@ -1040,6 +1041,14 @@
<string>EULA...</string>
</property>
</action>
<action name="mActionShowThreadDetails">
<property name="text">
<string>Thread Details</string>
</property>
<property name="toolTip">
<string>Show thread details</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
2 changes: 1 addition & 1 deletion gui/resultsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void ResultsView::setResultsSource(ResultsTree::ResultsSource source)
mUI->mTree->setResultsSource(source);
}

void ResultsView::progress(int value, const QString& description)
void ResultsView::filesCheckedProgress(int value, const QString& description)
{
mUI->mProgress->setValue(value);
mUI->mProgress->setFormat(QString("%p% (%1)").arg(description));
Expand Down
2 changes: 1 addition & 1 deletion gui/resultsview.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ public slots:
* @param value Current progress value
* @param description Description to accompany the progress
*/
void progress(int value, const QString& description);
void filesCheckedProgress(int value, const QString& description);

/**
* @brief Slot for new error to be displayed
Expand Down
14 changes: 13 additions & 1 deletion gui/test/resultstree/testresultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ void ThreadHandler::stop() {
void ThreadHandler::threadDone() {
throw 1;
}
// NOLINTBEGIN(performance-unnecessary-value-param)
void ThreadHandler::startCheck(CheckThread::Details /*unused*/) {
throw 1;
}
void ThreadHandler::finishCheck(CheckThread::Details /*unused*/) {
throw 1;
}
// NOLINTEND(performance-unnecessary-value-param)
Application& ApplicationList::getApplication(const int /*unused*/) {
throw 1;
}
Expand All @@ -106,7 +114,8 @@ QString XmlReport::unquoteMessage(const QString &message) {
return message;
}
XmlReport::XmlReport(const QString& filename) : Report(filename) {}
void ThreadResult::fileChecked(const QString & /*unused*/) {
// NOLINTNEXTLINE(performance-unnecessary-value-param)
void ThreadResult::finishCheck(CheckThread::Details /*unused*/) {
throw 1;
}
void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) {
Expand All @@ -115,6 +124,9 @@ void ThreadResult::reportOut(const std::string & /*unused*/, Color /*unused*/) {
void ThreadResult::reportErr(const ErrorMessage & /*unused*/) {
throw 1;
}
void ThreadResult::reportProgress(const std::string &/*filename*/, const char /*stage*/[], const std::size_t /*value*/) {
throw 1;
}

// Test...

Expand Down
51 changes: 51 additions & 0 deletions gui/threaddetails.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "threaddetails.h"
#include "ui_threaddetails.h"

#include <QMutexLocker>

ThreadDetails* ThreadDetails::mInstance;

ThreadDetails::ThreadDetails(QWidget *parent)
: QWidget(parent)
, mUi(new Ui::ThreadDetails)
{
mInstance = this;
setWindowFlags(Qt::Window);
mUi->setupUi(this);
connect(&mTimer, &QTimer::timeout, this, &ThreadDetails::updateUI);
mTimer.start(1000);
}

ThreadDetails::~ThreadDetails()
{
mInstance = nullptr;
delete mUi;
}

void ThreadDetails::threadDetailsUpdated(QMap<int, CheckThread::Details> threadDetails)
{
QMutexLocker locker(&mMutex);
mThreadDetails = threadDetails;
if (threadDetails.empty()) {
mProgress.clear();
}
}

void ThreadDetails::progress(QString filename, QString stage, std::size_t value) {
QMutexLocker locker(&mMutex);
mProgress[filename] = {QString(), stage + QString(value > 0 ? ": %1%" : "").arg(value)};
}

void ThreadDetails::updateUI() {
QString text("Thread\tStart time\tFile/Progress\n");
{
QMutexLocker locker(&mMutex);
for (const auto& td: mThreadDetails) {
auto& progress = mProgress[td.file];
if (progress.first.isEmpty() && !progress.second.isEmpty())
progress.first = QTime::currentTime().toString(Qt::TextDate);
text += QString("%1\t%2\t%3\n\t%4\t%5\n").arg(td.threadIndex).arg(td.startTime.toString(Qt::TextDate)).arg(td.file).arg(progress.first).arg(progress.second);
}
}
mUi->plainTextEdit->setPlainText(text);
}
Loading
Loading