forked from qt-creator/qt-creator
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:
@@ -224,12 +224,16 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void accept(Node *ast)
|
void accept(Node *ast)
|
||||||
{
|
{
|
||||||
|
if (m_futureInterface.isCanceled())
|
||||||
|
return;
|
||||||
if (ast)
|
if (ast)
|
||||||
ast->accept(this);
|
ast->accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scopedAccept(Node *ast, Node *child)
|
void scopedAccept(Node *ast, Node *child)
|
||||||
{
|
{
|
||||||
|
if (m_futureInterface.isCanceled())
|
||||||
|
return;
|
||||||
m_scopeBuilder.push(ast);
|
m_scopeBuilder.push(ast);
|
||||||
accept(child);
|
accept(child);
|
||||||
m_scopeBuilder.pop();
|
m_scopeBuilder.pop();
|
||||||
@@ -553,6 +557,7 @@ SemanticHighlighter::SemanticHighlighter(QmlJSEditorDocument *document)
|
|||||||
this, &SemanticHighlighter::applyResults);
|
this, &SemanticHighlighter::applyResults);
|
||||||
connect(&m_watcher, &QFutureWatcherBase::finished,
|
connect(&m_watcher, &QFutureWatcherBase::finished,
|
||||||
this, &SemanticHighlighter::finished);
|
this, &SemanticHighlighter::finished);
|
||||||
|
m_futureSynchronizer.setCancelOnWait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo)
|
void SemanticHighlighter::rerun(const QmlJSTools::SemanticInfo &semanticInfo)
|
||||||
|
Reference in New Issue
Block a user