From 2007aceab08382c0d6d5747608a1acb5b03b5f30 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 10 May 2021 18:45:37 +0200 Subject: [PATCH] Make SemanticHighlighter::run() cancelable In case the task needs to be canceled, stop doing its job and return as soon as possible. Change-Id: Id5a3462d9f0a19eda782aebdd4c25407318118db Reviewed-by: Christian Kandeler --- src/plugins/qmljseditor/qmljssemantichighlighter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index 8fac6e91ec9..9db93925a34 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -224,12 +224,16 @@ public: protected: void accept(Node *ast) { + if (m_futureInterface.isCanceled()) + return; if (ast) ast->accept(this); } void scopedAccept(Node *ast, Node *child) { + if (m_futureInterface.isCanceled()) + return; m_scopeBuilder.push(ast); accept(child); m_scopeBuilder.pop(); @@ -553,6 +557,7 @@ SemanticHighlighter::SemanticHighlighter(QmlJSEditorDocument *document) this, &SemanticHighlighter::applyResults); connect(&m_watcher, &QFutureWatcherBase::finished, this, &SemanticHighlighter::finished); + m_futureSynchronizer.setCancelOnWait(true); } void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo)