summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-08-24 12:21:02 +0200
committermae <qt-info@nokia.com>2009-08-24 14:53:03 +0200
commitc9d2f14b2a814fd29c858d9519e82fc5cbc2afdf (patch)
treefbf7ec0c5cd4204e2f64e24bb838b39fb3c74ec3
parente3078a5db9e092d78813180ce077789551929e4f (diff)
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)
-rw-r--r--src/gui/widgets/qplaintextedit.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index 384889d82..267de3809 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;