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>
This commit is contained in:
parent
0ed2c60fea
commit
7f640aa2eb
@ -1340,31 +1340,22 @@ QByteArray QMetaObject::normalizedSignature(const char *method)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Q_DECL_COLD_FUNCTION static inline bool
|
||||||
Returns the signatures of all methods whose name matches \a nonExistentMember,
|
printMethodNotFoundWarning(const QMetaObject *meta, QLatin1StringView name, qsizetype paramCount,
|
||||||
or an empty QByteArray if there are no matches.
|
const char *const *names)
|
||||||
*/
|
|
||||||
static inline QByteArray findMethodCandidates(const QMetaObject *metaObject, const char *nonExistentMember)
|
|
||||||
{
|
{
|
||||||
|
// now find the candidates we couldn't use
|
||||||
QByteArray candidateMessage;
|
QByteArray candidateMessage;
|
||||||
// Prevent full string comparison in every iteration.
|
for (int i = 0; i < meta->methodCount(); ++i) {
|
||||||
const QByteArray memberByteArray = nonExistentMember;
|
const QMetaMethod method = meta->method(i);
|
||||||
for (int i = 0; i < metaObject->methodCount(); ++i) {
|
if (method.name() == QByteArrayView(name))
|
||||||
const QMetaMethod method = metaObject->method(i);
|
|
||||||
if (method.name() == memberByteArray)
|
|
||||||
candidateMessage += " " + method.methodSignature() + '\n';
|
candidateMessage += " " + method.methodSignature() + '\n';
|
||||||
}
|
}
|
||||||
if (!candidateMessage.isEmpty()) {
|
if (!candidateMessage.isEmpty()) {
|
||||||
candidateMessage.prepend("\nCandidates are:\n");
|
candidateMessage.prepend("\nCandidates are:\n");
|
||||||
candidateMessage.chop(1);
|
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;
|
QVarLengthArray<char, 512> sig;
|
||||||
sig.append(name.data(), name.size());
|
sig.append(name.data(), name.size());
|
||||||
sig.append('(');
|
sig.append('(');
|
||||||
@ -1379,8 +1370,7 @@ printMethodNotFoundWarning(const QMetaObject *meta, QLatin1StringView name, qsiz
|
|||||||
sig.append('\0');
|
sig.append('\0');
|
||||||
|
|
||||||
qWarning("QMetaObject::invokeMethod: No such method %s::%s%s",
|
qWarning("QMetaObject::invokeMethod: No such method %s::%s%s",
|
||||||
meta->className(), sig.constData(),
|
meta->className(), sig.constData(), candidateMessage.constData());
|
||||||
findMethodCandidates(meta, name.data()).constData());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user