summaryrefslogtreecommitdiff
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:38:00 +0200
commitb01118f244ec45685407ebd393b1e44af8360add (patch)
tree8988f90268898f0ebf90963f86f6c3f2126bde41
parentd4aefc60abf3e014633b9a7544cb4b701864a061 (diff)
downloadqt4-tools-b01118f244ec45685407ebd393b1e44af8360add.tar.gz
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 20de404803..03c36d716d 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -573,7 +573,8 @@ 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;
@@ -583,7 +584,7 @@ QRectF QPlainTextEditControl::blockBoundingRect(const QTextBlock &block) const {
}
r = documentLayout->blockBoundingRect(currentBlock);
}
- while (currentBlockNumber > blockNumber && offset.y() >= -textEdit->viewport()->height()) {
+ while (currentBlockNumber > blockNumber && offset.y() + maxVerticalOffset >= -textEdit->viewport()->height()) {
currentBlock = currentBlock.previous();
--currentBlockNumber;
while (!currentBlock.isVisible()) {