From 022e3a358dcc6815d28a5103eb6562d4dc045a7c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 23 Aug 2012 11:37:45 +0200 Subject: Extract the QMetaMethodPrivate::ownMethodIndex method. Change-Id: Ic96e3582ff4332ac489f7c51ed40eb1b1a0ac42d Reviewed-by: Marc Mutz Reviewed-by: Kent Hansen --- src/corelib/kernel/qmetaobject.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 1024981d3b..e76efc35da 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -209,6 +209,7 @@ public: inline QList parameterTypes() const; inline QList parameterNames() const; inline QByteArray tag() const; + inline int ownMethodIndex() const; private: QMetaMethodPrivate(); @@ -851,7 +852,7 @@ int QMetaObjectPrivate::signalIndex(const QMetaMethod &m) { if (!m.mobj) return -1; - return ((m.handle - priv(m.mobj->d.data)->methodData) / 5) + signalOffset(m.mobj); + return QMetaMethodPrivate::get(&m)->ownMethodIndex() + signalOffset(m.mobj); } /*! @@ -1695,6 +1696,12 @@ QByteArray QMetaMethodPrivate::tag() const return stringData(mobj, mobj->d.data[handle + 3]); } +int QMetaMethodPrivate::ownMethodIndex() const +{ + // recompute the methodIndex by reversing the arithmetic in QMetaObject::property() + return (handle - priv(mobj->d.data)->methodData) / 5; +} + /*! \since 5.0 @@ -1885,7 +1892,7 @@ int QMetaMethod::methodIndex() const { if (!mobj) return -1; - return ((handle - priv(mobj->d.data)->methodData) / 5) + mobj->methodOffset(); + return QMetaMethodPrivate::get(this)->ownMethodIndex() + mobj->methodOffset(); } /*! @@ -1901,7 +1908,7 @@ int QMetaMethod::revision() const if ((QMetaMethod::Access)(mobj->d.data[handle + 4] & MethodRevisioned)) { int offset = priv(mobj->d.data)->methodData + priv(mobj->d.data)->methodCount * 5 - + (handle - priv(mobj->d.data)->methodData) / 5; + + QMetaMethodPrivate::get(this)->ownMethodIndex(); return mobj->d.data[offset]; } return 0; @@ -2120,8 +2127,7 @@ bool QMetaMethod::invoke(QObject *object, val8.data(), val9.data() }; - // recompute the methodIndex by reversing the arithmetic in QMetaObject::property() - int idx_relative = ((handle - priv(mobj->d.data)->methodData) / 5); + int idx_relative = QMetaMethodPrivate::get(this)->ownMethodIndex(); int idx_offset = mobj->methodOffset(); Q_ASSERT(QMetaObjectPrivate::get(mobj)->revision >= 6); QObjectPrivate::StaticMetaCallFunction callFunction = mobj->d.static_metacall; -- cgit v1.2.3