Skip to content

Commit

Permalink
Dedupe QMetaObject::cast
Browse files Browse the repository at this point in the history
By implementing in terms of QMetaObject::inherits().

Change-Id: I39a039539b05a20bc1713bd450d8a998c78433aa
Reviewed-by: Milian Wolff <[email protected]>
Reviewed-by: Olivier Goffart (Woboq GmbH) <[email protected]>
  • Loading branch information
seanharmer committed Mar 15, 2016
1 parent aa21ac1 commit ad9726d
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/corelib/kernel/qmetaobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,7 @@ QObject *QMetaObject::cast(QObject *obj) const
*/
const QObject *QMetaObject::cast(const QObject *obj) const
{
if (obj) {
const QMetaObject *m = obj->metaObject();
do {
if (m == this)
return obj;
} while ((m = m->d.superdata));
}
return 0;
return (obj && obj->metaObject()->inherits(this)) ? obj : nullptr;
}

#ifndef QT_NO_TRANSLATION
Expand Down

0 comments on commit ad9726d

Please sign in to comment.