From 0ad86983f4d746d2995720b895c14051556eeeee Mon Sep 17 00:00:00 2001 From: Frank Reininghaus Date: Mon, 22 Jul 2013 19:16:07 +0200 Subject: [PATCH] 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 --- src/kitemviews/private/kitemlistsmoothscroller.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 6987e1ce13..491461b806 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)