summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-08-09 10:50:37 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-08-10 00:48:31 +0200
commitcec3b3b4f90a1db642b8c3e03c493ab7d6c5f8a5 (patch)
treec09635309c10920000078d6978e78d37c8f6bc56 /src/corelib
parent395c9ac731e3789f336bad09cb4a8918a73be43d (diff)
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 <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp7
1 files changed, 3 insertions, 4 deletions
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<QByteArray> 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 {};