diff options
author | Christian Stenger <christian.stenger@qt.io> | 2016-07-08 12:53:57 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2016-07-15 09:18:01 +0000 |
commit | 48b2af5e773a39e8e3a342f1d082ff6bc1a96b54 (patch) | |
tree | f956bf3889a9a6d864bf5518e82bd5b6ea51baef /src/plugins/autotest/testcodeparser.cpp | |
parent | e70adf820ee42578f4a412572bedf3b745492619 (diff) | |
download | qt-creator-48b2af5e773a39e8e3a342f1d082ff6bc1a96b54.tar.gz |
AutoTest: Cancel possible running tasks on shutdown
If tasks are running while shutting down we might end up in a crash,
so cancel all tasks and handle possible invalid accesses of the
current running processing.
Change-Id: I69f7cac5f44390e322fa301af6d6794270c95c2a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/autotest/testcodeparser.cpp')
-rw-r--r-- | src/plugins/autotest/testcodeparser.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index 2680736e76..a86ec254e6 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -85,6 +85,8 @@ TestCodeParser::~TestCodeParser() void TestCodeParser::setState(State state) { + if (m_parserState == Shutdown) + return; qCDebug(LOG) << "setState(" << state << "), currentState:" << m_parserState; // avoid triggering parse before code model parsing has finished, but mark as dirty if (m_codeModelParsing) { @@ -175,6 +177,8 @@ static bool checkDocumentForTestCode(QFutureInterface<TestParseResultPtr> &futur const QVector<ITestParser *> &parsers) { foreach (ITestParser *currentParser, parsers) { + if (futureInterface.isCanceled()) + return false; if (currentParser->processDocument(futureInterface, fileName)) return true; } @@ -253,6 +257,17 @@ void TestCodeParser::onProjectPartsUpdated(ProjectExplorer::Project *project) emitUpdateTestTree(); } +void TestCodeParser::aboutToShutdown() +{ + qCDebug(LOG) << "Disabling (immediately) - shutting down"; + State oldState = m_parserState; + m_parserState = Shutdown; + if (oldState == PartialParse || oldState == FullParse) { + m_futureWatcher.cancel(); + m_futureWatcher.waitForFinished(); + } +} + bool TestCodeParser::postponed(const QStringList &fileList) { switch (m_parserState) { @@ -278,6 +293,7 @@ bool TestCodeParser::postponed(const QStringList &fileList) } return true; case Disabled: + case Shutdown: break; } QTC_ASSERT(false, return false); // should not happen at all @@ -285,7 +301,7 @@ bool TestCodeParser::postponed(const QStringList &fileList) void TestCodeParser::scanForTests(const QStringList &fileList) { - if (m_parserState == Disabled) { + if (m_parserState == Disabled || m_parserState == Shutdown) { m_dirty = true; if (fileList.isEmpty()) { m_fullUpdatePostponed = true; @@ -390,6 +406,9 @@ void TestCodeParser::onFinished() qCDebug(LOG) << "emitting parsingFinished (onFinished, Disabled)"; emit parsingFinished(); break; + case Shutdown: + qCDebug(LOG) << "Shutdown complete - not emitting parsingFinished (onFinished)"; + break; default: qWarning("I should not be here... State: %d", m_parserState); break; |