From ac54abfb07579c747612c0d9e53089fe5cd32caf Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 2 Dec 2013 22:23:11 +0100 Subject: Fix style animations to stop when the animation target is hidden QStyleAnimation automatically stopped for hidden QWidgets, but didn't know anything about QQuickItems and kept animating regardless of their visibility. This change ensures that style animations stop as soon as the animation target no longer accepts the animation update eg. it has become hidden or the window was minimized. Task-number: QTBUG-35319 Change-Id: Ie48191fd918c626c0d9afe2e7d2390c495efb071 Reviewed-by: Gunnar Sletta --- src/widgets/styles/qstyleanimation.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/widgets/styles/qstyleanimation.cpp') diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 4fb67d90c0..90fb371982 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -93,7 +93,10 @@ void QStyleAnimation::setStartTime(const QTime &time) void QStyleAnimation::updateTarget() { QEvent event(QEvent::StyleAnimationUpdate); + event.setAccepted(false); QCoreApplication::sendEvent(target(), &event); + if (!event.isAccepted()) + stop(); } bool QStyleAnimation::isUpdateNeeded() const @@ -103,16 +106,8 @@ bool QStyleAnimation::isUpdateNeeded() const void QStyleAnimation::updateCurrentTime(int) { - if (QObject *tgt = target()) { - if (tgt->isWidgetType()) { - QWidget *widget = static_cast(tgt); - if (!widget->isVisible() || widget->window()->isMinimized()) - stop(); - } - - if (isUpdateNeeded()) - updateTarget(); - } + if (target() && isUpdateNeeded()) + updateTarget(); } QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) : -- cgit v1.2.3