forked from qt-creator/qt-creator
QmlJS semantic highlighter: Abort when file changes.
Fixes the warning in incrementalApplyExtraAdditionalFormats being triggered when the document is reduced in size while a highlight is running. Change-Id: I60e0c8772d511f52ee433d27cc77ba726030b354 Reviewed-on: http://codereview.qt-project.org/4661 Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
@@ -1015,6 +1015,8 @@ void QmlJSTextEditorWidget::showTextMarker()
|
||||
|
||||
void QmlJSTextEditorWidget::updateUses()
|
||||
{
|
||||
if (m_semanticHighlighter->startRevision() != editorRevision())
|
||||
m_semanticHighlighter->cancel();
|
||||
m_updateUsesTimer->start();
|
||||
}
|
||||
|
||||
|
||||
@@ -386,6 +386,11 @@ void SemanticHighlighter::rerun(const ScopeChain &scopeChain)
|
||||
m_watcher.setFuture(f);
|
||||
}
|
||||
|
||||
void SemanticHighlighter::cancel()
|
||||
{
|
||||
m_watcher.cancel();
|
||||
}
|
||||
|
||||
void SemanticHighlighter::applyResults(int from, int to)
|
||||
{
|
||||
if (m_watcher.isCanceled())
|
||||
@@ -432,3 +437,7 @@ void SemanticHighlighter::updateFontSettings(const TextEditor::FontSettings &fon
|
||||
m_formats[LocalStateNameType] = fontSettings.toTextCharFormat(QLatin1String(TextEditor::Constants::C_QML_STATE_NAME));
|
||||
}
|
||||
|
||||
int SemanticHighlighter::startRevision() const
|
||||
{
|
||||
return m_startRevision;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,9 @@ public:
|
||||
SemanticHighlighter(QmlJSTextEditorWidget *editor);
|
||||
|
||||
void rerun(const QmlJS::ScopeChain &scopeChain);
|
||||
void cancel();
|
||||
|
||||
int startRevision() const;
|
||||
|
||||
void updateFontSettings(const TextEditor::FontSettings &fontSettings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user