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:
Eike Ziller
2019-09-26 11:28:04 +02:00
parent c2e6dd6958
commit 123aa77c49

View File

@@ -461,13 +461,13 @@ bool QLiteHtmlWidget::findText(const QString &text,
QRect newSelectionCombined;
for (const QRect &r : newSelection)
newSelectionCombined = newSelectionCombined.united(r);
if (success && verticalScrollBar()->value() > newSelectionCombined.top()) {
verticalScrollBar()->setValue(newSelectionCombined.top());
} else if (success
&& verticalScrollBar()->value() + toVirtual(viewport()->size()).height()
< newSelectionCombined.bottom()) {
verticalScrollBar()->setValue(newSelectionCombined.bottom()
- toVirtual(viewport()->size()).height());
QScrollBar *vBar = verticalScrollBar();
const int top = newSelectionCombined.top();
const int bottom = newSelectionCombined.bottom() - toVirtual(viewport()->size()).height();
if (success && top < vBar->value() && vBar->minimum() <= top) {
vBar->setValue(top);
} else if (success && vBar->value() < bottom && bottom <= vBar->maximum()) {
vBar->setValue(bottom);
} else {
viewport()->update(fromVirtual(newSelectionCombined.translated(-scrollPosition())));
for (const QRect &r : oldSelection)