From cec3b3b4f90a1db642b8c3e03c493ab7d6c5f8a5 Mon Sep 17 00:00:00 2001 From: Sami Shalayel Date: Tue, 9 Aug 2022 10:50:37 +0200 Subject: Remove assertion from ownMethodIndex that breaks tests ownMethodIndex works for all kind of methods, also for constructors. Therefore, remove the assertion there (that checks for non constructors) and add a test in qtbase so it does not happen again. The test broken by the assertion is in qtdeclarative: tst_QJSEngine::newQMetaObject(). Also rename QMetaMethodPrivate::ownConstructorIndex() to ownConstructorMethodIndex() as the previous naming implied that ownMethodIndex() could not be used for constructors. amends b73ab954dffffc462b6f6efe5a2dd97efeab0038 Task-number: QTBUG-105360 Change-Id: I0244993ed79bee055645b5443f5d02e1c089a6c6 Reviewed-by: Thiago Macieira Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qmetaobject.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f96354f0d2..7849bce771 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -189,7 +189,7 @@ public: inline QList parameterNames() const; inline QByteArray tag() const; inline int ownMethodIndex() const; - inline int ownConstructorIndex() const; + inline int ownConstructorMethodIndex() const; // shadows the public function enum class InvokeFailReason : int { @@ -1917,11 +1917,10 @@ QByteArray QMetaMethodPrivate::tag() const int QMetaMethodPrivate::ownMethodIndex() const { // recompute the methodIndex by reversing the arithmetic in QMetaObject::method() - Q_ASSERT(methodType() != Constructor); return ( data.d - mobj->d.data - priv(mobj->d.data)->methodData)/Data::Size; } -int QMetaMethodPrivate::ownConstructorIndex() const +int QMetaMethodPrivate::ownConstructorMethodIndex() const { // recompute the methodIndex by reversing the arithmetic in QMetaObject::constructor() Q_ASSERT(methodType() == Constructor); @@ -2471,7 +2470,7 @@ auto QMetaMethodPrivate::invokeImpl(QMetaMethod self, void *target, return InvokeFailReason::ConstructorCallWithoutResult; } - int idx = priv->ownConstructorIndex(); + int idx = priv->ownConstructorMethodIndex(); if (priv->mobj->static_metacall(QMetaObject::CreateInstance, idx, param) >= 0) return InvokeFailReason::ConstructorCallFailed; return {}; -- cgit v1.2.3