From 5f200ed5c7ea68e2c2b6f4ddeaeb77679f53d74b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Fri, 12 Jan 2024 20:33:55 +0100 Subject: [PATCH] AutoTest: Pass a list of results inside testParseResultsReady() This limits the number of signals being sent. Change-Id: Ie4b0661571a9d1bbd5708e33e21e0911e7a9fcbd Reviewed-by: Christian Stenger --- src/plugins/autotest/testcodeparser.cpp | 6 +++--- src/plugins/autotest/testcodeparser.h | 2 +- src/plugins/autotest/testtreemodel.cpp | 22 ++++++++++++---------- src/plugins/autotest/testtreemodel.h | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index d529ee8dccb..a6a32a707fc 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -384,9 +384,9 @@ void TestCodeParser::scanForTests(const QSet &filePaths, ++*storage; }; const auto onDone = [this](const Async &async) { - const QList results = async.results(); - for (const TestParseResultPtr &result : results) - emit testParseResultReady(result); + const QList &results = async.results(); + if (!results.isEmpty()) + emit testParseResultsReady(results); }; const Group root { parallelLimit(limit), diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 49e123ba496..5f215aad549 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -50,7 +50,7 @@ public: signals: void aboutToPerformFullParse(); - void testParseResultReady(const TestParseResultPtr result); // TODO: pass list of results? + void testParseResultsReady(const QList &results); void parsingStarted(); void parsingFinished(); void parsingFailed(); diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index 073ab32213f..638924db328 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -34,15 +34,15 @@ static Q_LOGGING_CATEGORY(LOG, "qtc.autotest.frameworkmanager", QtWarningMsg) static TestTreeModel *s_instance = nullptr; -TestTreeModel::TestTreeModel(TestCodeParser *parser) : - m_parser(parser) +TestTreeModel::TestTreeModel(TestCodeParser *parser) + : m_parser(parser) { s_instance = this; connect(m_parser, &TestCodeParser::aboutToPerformFullParse, this, &TestTreeModel::removeAllTestItems, Qt::QueuedConnection); - connect(m_parser, &TestCodeParser::testParseResultReady, - this, &TestTreeModel::onParseResultReady); + connect(m_parser, &TestCodeParser::testParseResultsReady, + this, &TestTreeModel::onParseResultsReady); connect(m_parser, &TestCodeParser::parsingFinished, this, &TestTreeModel::sweep, Qt::QueuedConnection); connect(m_parser, &TestCodeParser::parsingFailed, @@ -678,13 +678,15 @@ void TestTreeModel::revalidateCheckState(ITestTreeItem *item) } } -void TestTreeModel::onParseResultReady(const TestParseResultPtr result) +void TestTreeModel::onParseResultsReady(const QList &results) { - ITestFramework *framework = result->framework; - QTC_ASSERT(framework, return); - TestTreeItem *rootNode = framework->rootNode(); - QTC_ASSERT(rootNode, return); - handleParseResult(result.data(), rootNode); + for (const auto &result : results) { + ITestFramework *framework = result->framework; + QTC_ASSERT(framework, return); + TestTreeItem *rootNode = framework->rootNode(); + QTC_ASSERT(rootNode, return); + handleParseResult(result.data(), rootNode); + } } void Autotest::TestTreeModel::onDataChanged(const QModelIndex &topLeft, diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index 05c2e5e75de..9d5100ca2de 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -78,7 +78,7 @@ signals: #endif private: - void onParseResultReady(const TestParseResultPtr result); + void onParseResultsReady(const QList &results); void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector &roles); void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode);