forked from qt-creator/qt-creator
Help/litehtml: Guard against out-of-bounds scroll values
If we set the value of the scrollbar to an invalid value, nothing gets repainted, so we need to take the branch that calls update explicitly in that case. Change-Id: I700c690119b1ee2fe8b88d77c29e00f329810448 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -461,13 +461,13 @@ bool QLiteHtmlWidget::findText(const QString &text,
|
|||||||
QRect newSelectionCombined;
|
QRect newSelectionCombined;
|
||||||
for (const QRect &r : newSelection)
|
for (const QRect &r : newSelection)
|
||||||
newSelectionCombined = newSelectionCombined.united(r);
|
newSelectionCombined = newSelectionCombined.united(r);
|
||||||
if (success && verticalScrollBar()->value() > newSelectionCombined.top()) {
|
QScrollBar *vBar = verticalScrollBar();
|
||||||
verticalScrollBar()->setValue(newSelectionCombined.top());
|
const int top = newSelectionCombined.top();
|
||||||
} else if (success
|
const int bottom = newSelectionCombined.bottom() - toVirtual(viewport()->size()).height();
|
||||||
&& verticalScrollBar()->value() + toVirtual(viewport()->size()).height()
|
if (success && top < vBar->value() && vBar->minimum() <= top) {
|
||||||
< newSelectionCombined.bottom()) {
|
vBar->setValue(top);
|
||||||
verticalScrollBar()->setValue(newSelectionCombined.bottom()
|
} else if (success && vBar->value() < bottom && bottom <= vBar->maximum()) {
|
||||||
- toVirtual(viewport()->size()).height());
|
vBar->setValue(bottom);
|
||||||
} else {
|
} else {
|
||||||
viewport()->update(fromVirtual(newSelectionCombined.translated(-scrollPosition())));
|
viewport()->update(fromVirtual(newSelectionCombined.translated(-scrollPosition())));
|
||||||
for (const QRect &r : oldSelection)
|
for (const QRect &r : oldSelection)
|
||||||
|
|||||||
Reference in New Issue
Block a user