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
parent
78b8f7803b
commit
e1538b39bb
|
|
@ -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)));
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
|||
Loading…
Reference in New Issue