From: Rohan McGovern Date: Mon, 22 Oct 2012 04:19:24 +0000 (+1000) Subject: Fixed crash on destruction of animating QDockWidget in a QMainWindow X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=33214af3784feacb2d5188bbf07da92f45f582f9;p=profile%2Fivi%2Fqtbase.git Fixed crash on destruction of animating QDockWidget in a QMainWindow It doesn't make sense to hold an unguarded pointer to a QPropertyAnimation while assigning ownership of that animation to the animated widget. Destruction of the widget while the animation is in progress causes the animation pointer to become dangling; then the widget is removed from the containing QMainWindowLayout, which attempts to abort the animation, dereferencing the invalid pointer. The crash can be reproduced sometimes with tst_QDockWidget::taskQTBUG_2940_resizeAfterUndocking (which is in Qt4 only). Change-Id: I758bf7193b2ea39cd4d8e87197d8ff957d3368eb Reviewed-by: Robin Burchell Reviewed-by: Andy Shaw --- diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp index edd9d63..aef967b 100644 --- a/src/widgets/widgets/qwidgetanimator.cpp +++ b/src/widgets/widgets/qwidgetanimator.cpp @@ -59,7 +59,9 @@ void QWidgetAnimator::abort(QWidget *w) return; QPropertyAnimation *anim = *it; m_animation_map.erase(it); - anim->stop(); + if (anim) { + anim->stop(); + } #ifndef QT_NO_MAINWINDOW m_mainWindowLayout->animationFinished(w); #endif diff --git a/src/widgets/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h index 5649488..98963ce 100644 --- a/src/widgets/widgets/qwidgetanimator_p.h +++ b/src/widgets/widgets/qwidgetanimator_p.h @@ -55,6 +55,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -79,7 +80,7 @@ private Q_SLOTS: #endif private: - typedef QHash AnimationMap; + typedef QHash > AnimationMap; AnimationMap m_animation_map; QMainWindowLayout *m_mainWindowLayout; };