From 440e07da8ba3a303f30506eaca75a7b025e2abc4 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sat, 4 Aug 2012 19:38:41 +0200 Subject: [PATCH] Avoid using dynamic_casts in the timertop plugin. This fixes a crash in applications that are built without RTTI. --- plugins/timertop/timermodel.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/timertop/timermodel.cpp b/plugins/timertop/timermodel.cpp index 741cd001b1..c5041094ea 100644 --- a/plugins/timertop/timermodel.cpp +++ b/plugins/timertop/timermodel.cpp @@ -41,7 +41,7 @@ static TimerModel *s_timerModel = 0; static QTimer *timer_from_callback(QObject *caller, int method_index) { - QTimer * const timer = dynamic_cast(caller); + QTimer * const timer = qobject_cast(caller); if (timer) { QMetaMethod method = timer->metaObject()->method(method_index); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) @@ -307,8 +307,7 @@ bool TimerModel::eventFilter(QObject *watched, QEvent *event) { if (event->type() == QEvent::Timer) { - QTimerEvent * const timerEvent = dynamic_cast(event); - Q_ASSERT(timerEvent); + QTimerEvent * const timerEvent = static_cast(event); // If there is a QTimer associated with this timer ID, don't handle it here, it will be handled // by the signal hooks for QTimer::timeout()