From c9d2f14b2a814fd29c858d9519e82fc5cbc2afdf Mon Sep 17 00:00:00 2001 From: mae Date: Mon, 24 Aug 2009 12:21:02 +0200 Subject: Fix QPlainTextEdit painting errors With line wrapping enabled and very large text blocks, painting errors could occur. Reviewed-by: hjk (cherry picked from commit 82dba1d346a6f4a5d2602d930e0aed75c13bcafb) --- src/gui/widgets/qplaintextedit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 384889d..267de38 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -562,13 +562,14 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const { if (!block.isValid()) return QRectF(); QRectF r = documentLayout->blockBoundingRect(currentBlock); - while (currentBlockNumber < blockNumber && offset.y() <= 2* textEdit->viewport()->height()) { + int maxVerticalOffset = r.height(); + while (currentBlockNumber < blockNumber && offset.y() - maxVerticalOffset <= 2* textEdit->viewport()->height()) { offset.ry() += r.height(); currentBlock = currentBlock.next(); ++currentBlockNumber; r = documentLayout->blockBoundingRect(currentBlock); } - while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) { + while (currentBlockNumber > blockNumber && offset.y() + maxVerticalOffset >= -textEdit->viewport()->height()) { currentBlock = currentBlock.previous(); if (!currentBlock.isValid()) break; -- cgit v0.12