Avoid qobject_cast
authorKent Hansen <kent.hansen@nokia.com>
Tue, 31 Jul 2012 09:57:08 +0000 (11:57 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 31 Jul 2012 22:14:41 +0000 (00:14 +0200)
This is slightly faster, and also avoids accessing the object's meta
object that would cause any lazily created meta objects (e.g., for
QML) from being built.

This is just a port of commit a5972f8ec32631e70578c64e9d6c063b3c47f0f5
(which fixed QGuiApplication, but not QApplication).

Change-Id: I0d5080495aa4fd4486db297968c4d06bbfacf89b
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/widgets/kernel/qapplication.cpp

index dc09155..803d1ef 100644 (file)
@@ -2978,7 +2978,8 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
     d->checkReceiverThread(receiver);
 #endif
 
-    QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(qobject_cast<QWindow *>(receiver), e);
+    if (receiver->isWindowType())
+        QGuiApplicationPrivate::sendQWindowEventToQPlatformWindow(static_cast<QWindow *>(receiver), e);
 
     // capture the current mouse/keyboard state
     if(e->spontaneous()) {