Share code between const and non-const QMetaObject::cast variants.

Change-Id: I7aad8e5060bb17ebc04fdb137dad3b6d167895a8
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
bb10
Milian Wolff 2016-02-14 15:35:27 +01:00
parent 78b8f7803b
commit e1538b39bb
1 changed files with 2 additions and 8 deletions

View File

@ -333,14 +333,8 @@ const char *QMetaObject::className() const
*/
QObject *QMetaObject::cast(QObject *obj) const
{
if (obj) {
const QMetaObject *m = obj->metaObject();
do {
if (m == this)
return obj;
} while ((m = m->d.superdata));
}
return 0;
// ### Qt 6: inline
return const_cast<QObject*>(cast(const_cast<const QObject*>(obj)));
}
/*!