diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-09-12 12:58:59 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-09-12 13:30:09 +0200 |
commit | 5b88093b5d25ba2879cce8c13d9c40fe94e6953e (patch) | |
tree | 364f96cf45ddd96346d4cd9a5ff8a0009a5148fb /src | |
parent | c36e017d4056c6cbff887ee65bce0f9ff3809f28 (diff) | |
download | qt-creator-5b88093b5d25ba2879cce8c13d9c40fe94e6953e.tar.gz |
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>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljssemantichighlighter.cpp | 9 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljssemantichighlighter.h | 3 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index b39eec3c42..5ec720ff10 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1015,6 +1015,8 @@ void QmlJSTextEditorWidget::showTextMarker() void QmlJSTextEditorWidget::updateUses() { + if (m_semanticHighlighter->startRevision() != editorRevision()) + m_semanticHighlighter->cancel(); m_updateUsesTimer->start(); } diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp index c45fe9d514..dab142f85c 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.cpp +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.cpp @@ -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; +} diff --git a/src/plugins/qmljseditor/qmljssemantichighlighter.h b/src/plugins/qmljseditor/qmljssemantichighlighter.h index be5d7a175f..18ee030657 100644 --- a/src/plugins/qmljseditor/qmljssemantichighlighter.h +++ b/src/plugins/qmljseditor/qmljssemantichighlighter.h @@ -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); |