summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-12-14 16:13:23 (GMT)
committermae <qt-info@nokia.com>2009-12-14 16:20:03 (GMT)
commit764c4a456526ea07ce6c264139457f0e62968731 (patch)
tree4bf3131a3e63337dd66e971bda76f174a6f7246c /src/gui
parentbff37a821728615d5b1c766d1fbcb80bdccfb9fd (diff)
downloadQt-764c4a456526ea07ce6c264139457f0e62968731.zip
Qt-764c4a456526ea07ce6c264139457f0e62968731.tar.gz
Qt-764c4a456526ea07ce6c264139457f0e62968731.tar.bz2
QPlainTextEdit scrolling issue with folded paragraphs
With Qt Creator, we could reproduce scrolling problems when paragraphs were folded away. Effectively the first "visible" block could be an invisible one, resulting in firstVisibleBlock() returning something bogus. The result were drawing errors. Reviewed-by: con
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index b637c19..be24012 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -684,8 +684,12 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC
qreal h = center ? line.naturalTextRect().center().y() : line.naturalTextRect().bottom();
+ QTextBlock previousVisibleBlock = block;
while (h < height && block.previous().isValid()) {
- block = block.previous();
+ previousVisibleBlock = block;
+ do {
+ block = block.previous();
+ } while (!block.isVisible() && block.previous().isValid());
h += q->blockBoundingRect(block).height();
}
@@ -699,8 +703,8 @@ void QPlainTextEditPrivate::ensureVisible(int position, bool center, bool forceC
++l;
}
- if (block.next().isValid() && l >= lineCount) {
- block = block.next();
+ if (l >= lineCount) {
+ block = previousVisibleBlock;
l = 0;
}
setTopBlock(block.blockNumber(), l);