From: Frank Reininghaus Date: Mon, 22 Jul 2013 17:16:07 +0000 (+0200) Subject: Do not try to smooth-scroll past the end of the view X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/0ad86983f4d746d2995720b895c14051556eeeee Do not try to smooth-scroll past the end of the view KItemListSmoothScroller::scrollTo(qreal position) did not check if 'position' is a valid value. Even if the view is scrolled to the bottom already, it tried to scroll further and activated "smooth scrolling" when the mouse wheel is used. Because it never got out of the "smooth scrolling" state then, it got confused when changing the directory, and restoring the correct scroll offset could fail. BUG: 322212 FIXED-IN: 4.11.0 REVIEW: 111557 --- diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 6987e1ce1..491461b80 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -130,8 +130,13 @@ void KItemListSmoothScroller::scrollContentsBy(qreal distance) void KItemListSmoothScroller::scrollTo(qreal position) { - m_smoothScrolling = true; - m_scrollBar->setValue(position); + int newValue = position; + newValue = qBound(0, newValue, m_scrollBar->maximum()); + + if (newValue != m_scrollBar->value()) { + m_smoothScrolling = true; + m_scrollBar->setValue(newValue); + } } bool KItemListSmoothScroller::requestScrollBarUpdate(int newMaximum)