]> cloud.milkyroute.net Git - dolphin.git/commitdiff
KItemListSmoothScroller: stop animation on property or targetobject change
authorAkseli Lahtinen <akselmo@akselmo.dev>
Mon, 2 Dec 2024 09:40:03 +0000 (11:40 +0200)
committerAkseli Lahtinen <akselmo@akselmo.dev>
Mon, 2 Dec 2024 09:40:03 +0000 (11:40 +0200)
Due to changes in 15e0c2a98f480f203ce168b6fa9a2e1f2b0ed8f8 we do not
automatically stop animations now on property or targetobject change,
which causes warnings and timeouts.

This patch makes sure we stop them if their state is Running,
before modifying them.

See also:
https://invent.kde.org/system/dolphin/-/merge_requests/857#note_1083279

src/kitemviews/private/kitemlistsmoothscroller.cpp

index 517f6d983cc5c9a38e7673c1ad286677b7d31a7f..0e75460441abe4ba6c29bd5343d3384e0a2ab82e 100644 (file)
@@ -56,6 +56,9 @@ QScrollBar *KItemListSmoothScroller::scrollBar() const
 
 void KItemListSmoothScroller::setTargetObject(QObject *target)
 {
+    if (m_animation->state() == QAbstractAnimation::Running) {
+        m_animation->stop();
+    }
     m_animation->setTargetObject(target);
 }
 
@@ -66,6 +69,9 @@ QObject *KItemListSmoothScroller::targetObject() const
 
 void KItemListSmoothScroller::setPropertyName(const QByteArray &propertyName)
 {
+    if (m_animation->state() == QAbstractAnimation::Running) {
+        m_animation->stop();
+    }
     m_animation->setPropertyName(propertyName);
 }