Add qobject_cast template specialisation for QWindow

greatly improving the performance of qobject_cast<QWindow *>

Change-Id: If5a1afa6e41f4676f4838ea3ff80f1d89e396dfc
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
This commit is contained in:
Jørgen Lind 2014-10-23 13:58:08 +02:00 committed by Laszlo Agocs
parent 87eb3ea190
commit 14e51127cf

View File

@ -356,6 +356,19 @@ private:
friend Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window);
};
#ifndef Q_QDOC
template <> inline QWindow *qobject_cast<QWindow*>(QObject *o)
{
if (!o || !o->isWindowType()) return 0;
return static_cast<QWindow*>(o);
}
template <> inline const QWindow *qobject_cast<const QWindow*>(const QObject *o)
{
if (!o || !o->isWindowType()) return 0;
return static_cast<const QWindow*>(o);
}
#endif // !Q_QDOC
QT_END_NAMESPACE
#endif // QWINDOW_H