]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Do not try to smooth-scroll past the end of the view
authorFrank Reininghaus <frank78ac@googlemail.com>
Mon, 22 Jul 2013 17:16:07 +0000 (19:16 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Mon, 22 Jul 2013 17:16:07 +0000 (19:16 +0200)
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

index 6987e1ce13303ab1a72fb7444376f7ba03c1adaf..491461b806bc438bbac6cc11e03cc0ddb7bcc943 100644 (file)
@@ -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)