Dedupe QMetaObject::cast
By implementing in terms of QMetaObject::inherits(). Change-Id: I39a039539b05a20bc1713bd450d8a998c78433aa Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
aa21ac1043
commit
ad9726d99c
@ -363,14 +363,7 @@ QObject *QMetaObject::cast(QObject *obj) const
|
|||||||
*/
|
*/
|
||||||
const QObject *QMetaObject::cast(const QObject *obj) const
|
const QObject *QMetaObject::cast(const QObject *obj) const
|
||||||
{
|
{
|
||||||
if (obj) {
|
return (obj && obj->metaObject()->inherits(this)) ? obj : nullptr;
|
||||||
const QMetaObject *m = obj->metaObject();
|
|
||||||
do {
|
|
||||||
if (m == this)
|
|
||||||
return obj;
|
|
||||||
} while ((m = m->d.superdata));
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef QT_NO_TRANSLATION
|
#ifndef QT_NO_TRANSLATION
|
||||||
|
Loading…
x
Reference in New Issue
Block a user