diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-15 13:42:23 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-07-28 11:50:17 -0700 |
commit | 7f640aa2ebf02951abc0b5fb874c91b48b0e307f (patch) | |
tree | 32b49f368bacb603621ef7e2afc646a509a7cab6 /src/corelib/kernel/qmetaobject.cpp | |
parent | 0ed2c60fea9b923f70dad7a8e591df2da80e76db (diff) |
QMetaObject: merge the findMethodCandidates() into the warning function
It's only used there anyway.
Change-Id: I36b24183fbd041179f2ffffd17021b6768055bfa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qmetaobject.cpp')
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 5c436b805a..555e49206a 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1340,31 +1340,22 @@ QByteArray QMetaObject::normalizedSignature(const char *method) return result; } -/* - Returns the signatures of all methods whose name matches \a nonExistentMember, - or an empty QByteArray if there are no matches. -*/ -static inline QByteArray findMethodCandidates(const QMetaObject *metaObject, const char *nonExistentMember) +Q_DECL_COLD_FUNCTION static inline bool +printMethodNotFoundWarning(const QMetaObject *meta, QLatin1StringView name, qsizetype paramCount, + const char *const *names) { + // now find the candidates we couldn't use QByteArray candidateMessage; - // Prevent full string comparison in every iteration. - const QByteArray memberByteArray = nonExistentMember; - for (int i = 0; i < metaObject->methodCount(); ++i) { - const QMetaMethod method = metaObject->method(i); - if (method.name() == memberByteArray) + for (int i = 0; i < meta->methodCount(); ++i) { + const QMetaMethod method = meta->method(i); + if (method.name() == QByteArrayView(name)) candidateMessage += " " + method.methodSignature() + '\n'; } if (!candidateMessage.isEmpty()) { candidateMessage.prepend("\nCandidates are:\n"); candidateMessage.chop(1); } - return candidateMessage; -} -Q_DECL_COLD_FUNCTION static inline bool -printMethodNotFoundWarning(const QMetaObject *meta, QLatin1StringView name, qsizetype paramCount, - const char *const *names) -{ QVarLengthArray<char, 512> sig; sig.append(name.data(), name.size()); sig.append('('); @@ -1379,8 +1370,7 @@ printMethodNotFoundWarning(const QMetaObject *meta, QLatin1StringView name, qsiz sig.append('\0'); qWarning("QMetaObject::invokeMethod: No such method %s::%s%s", - meta->className(), sig.constData(), - findMethodCandidates(meta, name.data()).constData()); + meta->className(), sig.constData(), candidateMessage.constData()); return false; } |