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 <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2021-05-10 18:45:37 +02:00
parent 1e26327472
commit 2007aceab0

View File

@@ -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)