From 9a126e37f977c2f29f52eea3d2574a8eae23d0f2 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 8 Mar 2017 08:52:24 +0100 Subject: [PATCH] AutoTest: Handle conflicting update triggers If a postponed update should be done for a single parser only and another full update for all is triggered the latter one would be ignored which is wrong. An update for all parsers should always have higher priority and replace a possible scheduled update for a single parser. Change-Id: I5e1e446c7dcb9ddbcaed4606ff87a894235b723e Reviewed-by: David Schulz --- src/plugins/autotest/testcodeparser.cpp | 11 +++++++++-- src/plugins/autotest/testcodeparser.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 8707da8a1c4..40bb7ab0752 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -136,13 +136,16 @@ void TestCodeParser::emitUpdateTestTree(ITestParser *parser) if (m_testCodeParsers.isEmpty()) return; if (m_singleShotScheduled) { + if (m_updateParser && parser != m_updateParser) + m_updateParser = nullptr; qCDebug(LOG) << "not scheduling another updateTestTree"; return; } qCDebug(LOG) << "adding singleShot"; m_singleShotScheduled = true; - QTimer::singleShot(1000, this, [this, parser](){ updateTestTree(parser); }); + m_updateParser = parser; + QTimer::singleShot(1000, this, [this](){ updateTestTree(m_updateParser); }); } void TestCodeParser::updateTestTree(ITestParser *parser) @@ -152,6 +155,8 @@ void TestCodeParser::updateTestTree(ITestParser *parser) m_fullUpdatePostponed = true; m_partialUpdatePostponed = false; m_postponedFiles.clear(); + if (!parser || parser != m_updateParser) + m_updateParser = nullptr; return; } @@ -452,6 +457,7 @@ void TestCodeParser::onFinished() } else { qCDebug(LOG) << "emitting parsingFinished" << "(onFinished, FullParse, nothing postponed, parsing succeeded)"; + m_updateParser = nullptr; emit parsingFinished(); qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "ParsingFin"; } @@ -474,7 +480,7 @@ void TestCodeParser::onPartialParsingFinished() if (m_fullUpdatePostponed) { m_fullUpdatePostponed = false; qCDebug(LOG) << "calling updateTestTree (onPartialParsingFinished)"; - updateTestTree(); + updateTestTree(m_updateParser); } else if (m_partialUpdatePostponed) { m_partialUpdatePostponed = false; qCDebug(LOG) << "calling scanForTests with postponed files (onPartialParsingFinished)"; @@ -488,6 +494,7 @@ void TestCodeParser::onPartialParsingFinished() } else if (!m_singleShotScheduled) { qCDebug(LOG) << "emitting parsingFinished" << "(onPartialParsingFinished, nothing postponed, not dirty)"; + m_updateParser = nullptr; emit parsingFinished(); qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "ParsingFin"; } else { diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 55a381139b9..6286600c335 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -105,6 +105,7 @@ private: QFutureWatcher m_futureWatcher; QVector m_testCodeParsers; // ptrs are still owned by TestFrameworkManager QTimer m_reparseTimer; + ITestParser *m_updateParser = nullptr; }; } // namespace Internal