summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetaobject.cpp
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2020-08-18 16:36:53 +0200
committerFabian Kosmale <fabian.kosmale@qt.io>2020-08-28 00:41:00 +0200
commit4d5a048d96f1161e2059315d0fe350fdcebb2e05 (patch)
treeaf326c4ac72a449d9a168d657a68c96567fe2ca3 /src/corelib/kernel/qmetaobject.cpp
parent462b36c3dee591bd964670dc614b995ece335331 (diff)
Improve connect: Use existing metatypes if possible
As there is now a chance that a QMetaMethod already contains the metatypes for its arguments, we can just query it directly (and use the fallback to name lookup logic that already exists there). This also allows us to avoid creating a QList of names, and only requires us to do a name lookup in case the connection actually fails. Change-Id: Idda30bc4b538a94476ae6c533776c22340f0030d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
-rw-r--r--src/corelib/kernel/qmetaobject.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index e584fbba8e..f0cef22b6f 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -207,6 +207,7 @@ public:
inline uint parameterTypeInfo(int index) const;
inline int parameterType(int index) const;
inline void getParameterTypes(int *types) const;
+ inline QByteArray parameterTypeName(int index) const;
inline QList<QByteArray> parameterTypes() const;
inline QList<QByteArray> parameterNames() const;
inline QByteArray tag() const;
@@ -1780,6 +1781,12 @@ void QMetaMethodPrivate::getParameterTypes(int *types) const
}
}
+QByteArray QMetaMethodPrivate::parameterTypeName(int index) const
+{
+ int paramsIndex = parametersDataIndex();
+ return typeNameFromTypeInfo(mobj, mobj->d.data[paramsIndex + index]);
+}
+
QList<QByteArray> QMetaMethodPrivate::parameterTypes() const
{
Q_ASSERT(priv(mobj->d.data)->revision >= 7);
@@ -1961,6 +1968,20 @@ QList<QByteArray> QMetaMethod::parameterTypes() const
}
/*!
+ \since 6.0
+ Returns the name of the type at position \a index
+ If there is no parameter at \a index, returns an empty QByteArray
+
+ \sa parameterNames()
+ */
+QByteArray QMetaMethod::parameterTypeName(int index) const
+{
+ if (!mobj || index < 0 || index >= parameterCount())
+ return {};
+ return QMetaMethodPrivate::get(this)->parameterTypeName(index);
+}
+
+/*!
Returns a list of parameter names.
\sa parameterTypes(), methodSignature()