diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-16 10:52:07 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-16 20:55:31 +0100 |
commit | bda6200192b25b4cbb5b0bed027509d67e31c97b (patch) | |
tree | 4735ef71225380ec9d9183cb473bf48be6662992 /src/qml/qml | |
parent | f3e981afb4d10c4e249c1738df9afc3d75328986 (diff) |
QtQml: Clean up QQmlMetaObject::canConvert()
I don't see how the previous implementation makes any sense. It seems to
be a remnant of a time when QMetaObject::inherits() didn't work
reliably.
Task-number: QTBUG-94807
Change-Id: I9b7a25aa641185c263ddc6d91553400259e4a311
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlmetaobject.cpp | 22 | ||||
-rw-r--r-- | src/qml/qml/qqmlmetaobject_p.h | 6 |
2 files changed, 5 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlmetaobject.cpp b/src/qml/qml/qqmlmetaobject.cpp index e84c5a366e..d5f1fb3b96 100644 --- a/src/qml/qml/qqmlmetaobject.cpp +++ b/src/qml/qml/qqmlmetaobject.cpp @@ -8,28 +8,6 @@ QT_BEGIN_NAMESPACE -// Returns true if \a from is assignable to a property of type \a to -bool QQmlMetaObject::canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to) -{ - Q_ASSERT(!from.isNull() && !to.isNull()); - - auto equal = [] (const QMetaObject *lhs, const QMetaObject *rhs) -> bool { - return lhs == rhs || (lhs && rhs && lhs->d.stringdata == rhs->d.stringdata); - }; - - const QMetaObject *tom = to.metaObject(); - if (tom == &QObject::staticMetaObject) return true; - - const QMetaObject *fromm = from.metaObject(); - while (fromm) { - if (equal(fromm, tom)) - return true; - fromm = fromm->superClass(); - } - - return false; -} - void QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, const QMetaObject **metaObject, int *index) { int offset; diff --git a/src/qml/qml/qqmlmetaobject_p.h b/src/qml/qml/qqmlmetaobject_p.h index cc3cc6af79..288779c74c 100644 --- a/src/qml/qml/qqmlmetaobject_p.h +++ b/src/qml/qml/qqmlmetaobject_p.h @@ -67,7 +67,11 @@ public: bool constructorParameterTypes(int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError) const; - static bool canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to); + static bool canConvert(const QQmlMetaObject &from, const QQmlMetaObject &to) + { + Q_ASSERT(!from.isNull() && !to.isNull()); + return from.metaObject()->inherits(to.metaObject()); + } // static_metacall (on Gadgets) doesn't call the base implementation and therefore // we need a helper to find the correct meta object and property/method index. |