diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2012-10-16 17:39:52 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-17 20:47:16 +0200 |
commit | 9d86458d8c0f823beff25eb676469bdc686cd285 (patch) | |
tree | ff18e7890a86b0e2e2624a6ab14a2b0a57a3726c /src/widgets/styles/qstyleanimation.cpp | |
parent | a98b9435579f5abef82036e81af4488d8a464b66 (diff) |
Fix potential crash in QStyleAnimation::updateCurrentTime()
A parentless/targetless QStyleAnimation calls updateCurrentTime() from
QAbstractAnimation constructor. Avoid the potential crash even if it's
not a valid use case for QStyleAnimation.
Change-Id: I9cd263d105c8ea4b5cbabac9a7680991745ccd95
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles/qstyleanimation.cpp')
-rw-r--r-- | src/widgets/styles/qstyleanimation.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/widgets/styles/qstyleanimation.cpp b/src/widgets/styles/qstyleanimation.cpp index 297a929970..6173dc9ddb 100644 --- a/src/widgets/styles/qstyleanimation.cpp +++ b/src/widgets/styles/qstyleanimation.cpp @@ -83,15 +83,17 @@ bool QStyleAnimation::isUpdateNeeded() const void QStyleAnimation::updateCurrentTime(int) { - if (target()->isWidgetType()) { - QWidget *widget = static_cast<QWidget *>(target()); - if (!widget->isVisible() || widget->window()->isMinimized()) - stop(); - } - - if (isUpdateNeeded()) { - QEvent event(QEvent::StyleAnimationUpdate); - QCoreApplication::sendEvent(target(), &event); + if (QObject *tgt = target()) { + if (tgt->isWidgetType()) { + QWidget *widget = static_cast<QWidget *>(tgt); + if (!widget->isVisible() || widget->window()->isMinimized()) + stop(); + } + + if (isUpdateNeeded()) { + QEvent event(QEvent::StyleAnimationUpdate); + QCoreApplication::sendEvent(tgt, &event); + } } } |