diff --git a/src/plugins/qmlpreview/qmlpreviewplugin.cpp b/src/plugins/qmlpreview/qmlpreviewplugin.cpp index 3b0f8c281f2..d87d0516a1e 100644 --- a/src/plugins/qmlpreview/qmlpreviewplugin.cpp +++ b/src/plugins/qmlpreview/qmlpreviewplugin.cpp @@ -505,8 +505,11 @@ void QmlPreviewPluginPrivate::checkDocument(const QString &name, const QByteArra const auto onParseSetup = [name, contents, dialect](Utils::Async &async) { async.setConcurrentCallData(parse, name, contents, dialect); }; - const auto onParseDone = [this, name, contents] { triggerPreview(name, contents); }; - m_parseRunner.start({Utils::AsyncTask(onParseSetup, onParseDone, CallDoneIf::Success)}); + const auto onDone = [this, name, contents](DoneWith result) { + if (result == DoneWith::Success) + triggerPreview(name, contents); + }; + m_parseRunner.start({Utils::AsyncTask(onParseSetup)}, {}, onDone); } } // namespace QmlPreview diff --git a/tests/auto/solutions/tasking/tst_tasking.cpp b/tests/auto/solutions/tasking/tst_tasking.cpp index e1f37bbc001..80d581ac6b3 100644 --- a/tests/auto/solutions/tasking/tst_tasking.cpp +++ b/tests/auto/solutions/tasking/tst_tasking.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -124,6 +125,7 @@ private slots: void nestedBrokenStorage(); void restart(); void destructorOfTaskEmittingDone(); + void restartTaskTreeRunnerFromDoneHandler(); void validConditionalConstructs(); }; @@ -4251,6 +4253,21 @@ void tst_Tasking::destructorOfTaskEmittingDone() taskTree.start(); } +void tst_Tasking::restartTaskTreeRunnerFromDoneHandler() +{ + TaskTreeRunner runner; + QStringList log; + QStringList expectedLog{"1", "2"}; + + const auto onFirstDone = [&runner, &log](DoneWith) { + log.append("1"); + runner.start({TestTask()}, {}, [&log](DoneWith) { log.append("2"); }); + }; + runner.start({TestTask()}, {}, onFirstDone); + QTRY_VERIFY(!runner.isRunning()); + QCOMPARE(log, expectedLog); +} + void tst_Tasking::validConditionalConstructs() { const TestTask condition;