diff options
| author | Semih Yavuz <semih.yavuz@qt.io> | 2023-01-06 18:39:43 +0300 |
|---|---|---|
| committer | Semih Yavuz <semih.yavuz@qt.io> | 2023-01-10 15:09:23 +0300 |
| commit | afc7928d1a1e47ecbc9d101c4e5d5fb1c5b78326 (patch) | |
| tree | ea709cb4752ba747b6670b23be2df268e8aa7ae4 /src/qmlcompiler/qqmljsutils.cpp | |
| parent | 1609f8628d1469f723a762c60ccb5856637956dc (diff) | |
QmlCachegen: Equality comparison ability to QObject *
We should be able to compare QObject * with QObject * or a
nullptr.
Pick-to: 6.5
Fixes: QTBUG-109377
Change-Id: I0e9d6fdc89cbb471774d6382316dfb4813310e1d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsutils.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsutils.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsutils.cpp b/src/qmlcompiler/qqmljsutils.cpp index 2e054c04df..b582bf67fc 100644 --- a/src/qmlcompiler/qqmljsutils.cpp +++ b/src/qmlcompiler/qqmljsutils.cpp @@ -222,4 +222,24 @@ bool canCompareWithVar(const QQmlJSTypeResolver *typeResolver, || typeResolver->equals(lhsType, voidType))); } +/*! \internal + + Utility method that checks if one of the registers is qobject, and the other can be + efficiently compared to it +*/ +bool canCompareWithQObject(const QQmlJSTypeResolver *typeResolver, + const QQmlJSRegisterContent &lhsContent, + const QQmlJSRegisterContent &rhsContent) +{ + Q_ASSERT(typeResolver); + const auto lhsType = typeResolver->containedType(lhsContent); + const auto rhsType = typeResolver->containedType(rhsContent); + return (lhsType->isReferenceType() + && (rhsType->isReferenceType() + || typeResolver->equals(rhsType, typeResolver->nullType()))) + || (rhsType->isReferenceType() + && (lhsType->isReferenceType() + || typeResolver->equals(lhsType, typeResolver->nullType()))); +} + QT_END_NAMESPACE |
