diff options
author | Christian Kamm <christian.d.kamm@nokia.com> | 2011-09-16 09:50:17 +0200 |
---|---|---|
committer | Christian Kamm <christian.d.kamm@nokia.com> | 2011-09-16 10:20:45 +0200 |
commit | 4dc13ab09fb42090ff4552f789b78dca16652c45 (patch) | |
tree | d0c3683e01707afd7b61da0e11a179973e66632d /src/plugins/texteditor/semantichighlighter.cpp | |
parent | 9d730da17a3183add69969755ec8d301f7b1216c (diff) |
SemanticHighlighter: Fix off-by-one in assert.
Change-Id: Ie9331d233894e49cf86605819687eeef765272df
Reviewed-on: http://codereview.qt-project.org/5067
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
Diffstat (limited to 'src/plugins/texteditor/semantichighlighter.cpp')
-rw-r--r-- | src/plugins/texteditor/semantichighlighter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/texteditor/semantichighlighter.cpp b/src/plugins/texteditor/semantichighlighter.cpp index 0e541e8f41..ba36dc9c1a 100644 --- a/src/plugins/texteditor/semantichighlighter.cpp +++ b/src/plugins/texteditor/semantichighlighter.cpp @@ -125,8 +125,13 @@ void TextEditor::SemanticHighlighter::clearExtraAdditionalFormatsUntilEnd( } QTextDocument *doc = highlighter->document(); - QTC_ASSERT(lastBlockNumber + 1 < doc->blockCount(), return); - QTextBlock b = doc->findBlockByNumber(lastBlockNumber + 1); + + const int firstBlockToClear = lastBlockNumber + 1; + if (firstBlockToClear == doc->blockCount()) + return; + QTC_ASSERT(firstBlockToClear < doc->blockCount(), return); + + QTextBlock b = doc->findBlockByNumber(firstBlockToClear); while (b.isValid()) { highlighter->setExtraAdditionalFormats(b, QList<QTextLayout::FormatRange>()); |