From 7357119b1a58b04051dd1c2a971a4bd72dcc6284 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 29 Jun 2017 11:05:24 +0300 Subject: [PATCH] Fix scroll top overflow. Fixes #3524 --- Telegram/SourceFiles/historywidget.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 00d8a0c23e..7818fbd921 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -5045,7 +5045,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S _updateHistoryGeometryRequired = false; if ((!initial && !wasAtBottom) || (loadedDown && (!_history->showFrom || _history->unreadBar || _history->loadedAtBottom()) && (!_migrated || !_migrated->showFrom || _migrated->unreadBar || _history->loadedAtBottom()))) { - auto toY = _list->historyScrollTop(); + auto toY = qMin(_list->historyScrollTop(), _scroll->scrollTopMax()); if (change.type == ScrollChangeAdd) { toY += change.value; } else if (change.type == ScrollChangeNoJumpToBottom) { @@ -5054,9 +5054,7 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S toY += _addToScroll; _addToScroll = 0; } - if (toY > _scroll->scrollTopMax()) { - toY = _scroll->scrollTopMax(); - } + toY = snap(toY, 0, _scroll->scrollTopMax()); if (_scroll->scrollTop() == toY) { visibleAreaUpdated(); } else {