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>
This commit is contained in:
Christian Kamm
2011-09-16 09:50:17 +02:00
parent 9d730da17a
commit 4dc13ab09f

View File

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