Skip to content

Commit 67caad0

Browse files
committed
Fix #14359 (GUI: Duplicate warnings are not filtered out) (#8077)
1 parent 9730a44 commit 67caad0

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

gui/resultstree.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ bool ResultsTree::addErrorItem(const ErrorItem& errorItem)
239239
if (errorItem.errorPath.isEmpty())
240240
return false;
241241

242+
const QString s = errorItem.toString();
243+
if (mErrorList.contains(s))
244+
return false;
245+
mErrorList.append(s);
246+
242247
QSharedPointer<ErrorItem> errorItemPtr{new ErrorItem(errorItem)};
243248

244249
if (mReportType != ReportType::normal) {
@@ -393,6 +398,8 @@ ResultItem *ResultsTree::findFileItem(const QString &name) const
393398

394399
void ResultsTree::clear()
395400
{
401+
mErrorList.clear();
402+
396403
mModel->removeRows(0, mModel->rowCount());
397404

398405
if (const ProjectFile *activeProject = ProjectFile::getActiveProject()) {
@@ -419,6 +426,7 @@ void ResultsTree::clear(const QString &filename)
419426
if (stripped == fileItem->text() ||
420427
filename == fileItem->errorItem->file0) {
421428
mModel->removeRow(i);
429+
mErrorList.removeAll(fileItem->errorItem->toString());
422430
break;
423431
}
424432
}
@@ -436,6 +444,7 @@ void ResultsTree::clearRecheckFile(const QString &filename)
436444
storedfile = ((!mCheckPath.isEmpty() && storedfile.startsWith(mCheckPath)) ? storedfile.mid(mCheckPath.length() + 1) : storedfile);
437445
if (actualfile == storedfile) {
438446
mModel->removeRow(i);
447+
mErrorList.removeAll(fileItem->errorItem->toString());
439448
break;
440449
}
441450
}

gui/resultstree.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ protected slots:
568568

569569
QStringList mHiddenMessageId;
570570

571+
// List of existing errors so we can avoid duplicates
572+
QStringList mErrorList;
573+
571574
QItemSelectionModel* mSelectionModel{};
572575
ThreadHandler *mThread{};
573576

gui/test/resultstree/testresultstree.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,19 @@ void TestResultsTree::test1() const
134134
QCOMPARE(tree.isRowHidden(0,QModelIndex()), false); // Show item
135135
}
136136

137+
void TestResultsTree::duplicateResults() const
138+
{
139+
// #14359 - filter out duplicate warnings
140+
ResultsTree tree(nullptr);
141+
142+
ErrorItem errorItem;
143+
errorItem.summary = errorItem.message = "test";
144+
errorItem.severity = Severity::error;
145+
errorItem.errorPath << QErrorPathItem();
146+
QVERIFY(tree.addErrorItem(errorItem));
147+
QVERIFY(!tree.addErrorItem(errorItem));
148+
}
149+
137150
static QErrorPathItem createErrorPathItem(QString file, int line, int column, QString info) {
138151
QErrorPathItem ret;
139152
ret.file = std::move(file);

gui/test/resultstree/testresultstree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class TestResultsTree : public QObject {
2323

2424
private slots:
2525
void test1() const;
26+
void duplicateResults() const;
2627
void multiLineResult() const;
2728
void resultsInSameFile() const;
2829
void testReportType() const;

0 commit comments

Comments
 (0)