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(target()); - if (!widget->isVisible() || widget->window()->isMinimized()) - stop(); - } + if (QObject *tgt = target()) { + if (tgt->isWidgetType()) { + QWidget *widget = static_cast(tgt); + if (!widget->isVisible() || widget->window()->isMinimized()) + stop(); + } - if (isUpdateNeeded()) { - QEvent event(QEvent::StyleAnimationUpdate); - QCoreApplication::sendEvent(target(), &event); + if (isUpdateNeeded()) { + QEvent event(QEvent::StyleAnimationUpdate); + QCoreApplication::sendEvent(tgt, &event); + } } }