From 6c55cf4b6a89d0d58ee7a29122ac68ac70fad65c Mon Sep 17 00:00:00 2001 From: Akseli Lahtinen Date: Mon, 2 Dec 2024 11:40:03 +0200 Subject: [PATCH] KItemListSmoothScroller: stop animation on property or targetobject change 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/kitemviews/private/kitemlistsmoothscroller.cpp b/src/kitemviews/private/kitemlistsmoothscroller.cpp index 517f6d983..0e7546044 100644 --- a/src/kitemviews/private/kitemlistsmoothscroller.cpp +++ b/src/kitemviews/private/kitemlistsmoothscroller.cpp @@ -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); } -- 2.47.3