QDBusConnection: output error message from findSlot
This helps debugging why an adaptor's method fails to be called. Example output: QDBusConnection: couldn't handle call to LaunchCommand: Type not registered with QtDBus in parameter list: QByteArrayList tests/auto/dbus/qdbusmarshall/tst_qdbusmarshall shows many warnings after this commit, since it's testing many cases of "no such slot". Pick-to: 6.0 6.1 5.15 Change-Id: Ic4ddcd91d005555a02d531fc8960aea2c809e20b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c1415a6a6c
commit
6ea2a12e27
@ -665,6 +665,7 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
|
||||
const QString &signature_, QList<QMetaType> &metaTypes)
|
||||
{
|
||||
QByteArray msgSignature = signature_.toLatin1();
|
||||
QString parametersErrorMsg;
|
||||
|
||||
for (int idx = mo->methodCount() - 1 ; idx >= QObject::staticMetaObject.methodCount(); --idx) {
|
||||
QMetaMethod mm = mo->method(idx);
|
||||
@ -691,8 +692,10 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
|
||||
|
||||
QString errorMsg;
|
||||
int inputCount = qDBusParametersForMethod(mm, metaTypes, errorMsg);
|
||||
if (inputCount == -1)
|
||||
if (inputCount == -1) {
|
||||
parametersErrorMsg = errorMsg;
|
||||
continue; // problem parsing
|
||||
}
|
||||
|
||||
metaTypes[0] = returnType;
|
||||
bool hasMessage = false;
|
||||
@ -754,6 +757,13 @@ static int findSlot(const QMetaObject *mo, const QByteArray &name, int flags,
|
||||
}
|
||||
|
||||
// no slot matched
|
||||
if (!parametersErrorMsg.isEmpty()) {
|
||||
qCWarning(dbusIntegration, "QDBusConnection: couldn't handle call to %s: %ls",
|
||||
name.constData(), qUtf16Printable(parametersErrorMsg));
|
||||
} else {
|
||||
qCWarning(dbusIntegration, "QDBusConnection: couldn't handle call to %s, no slot matched",
|
||||
name.constData());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusConnection>
|
||||
#include <QLoggingCategory>
|
||||
|
||||
static const char serviceName[] = "org.qtproject.autotests.qpong";
|
||||
static const char objectPath[] = "/org/qtproject/qpong";
|
||||
@ -32,6 +33,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
// Silence many warnings from findSlot() about ping() not having the expected argument types
|
||||
QLoggingCategory::setFilterRules("qt.dbus.integration=false");
|
||||
|
||||
QDBusConnection con = QDBusConnection::sessionBus();
|
||||
if (!con.isConnected())
|
||||
exit(1);
|
||||
|
@ -1146,6 +1146,7 @@ void tst_QDBusMarshall::receiveUnknownType()
|
||||
// now spin our event loop. We don't catch this call, so let's get the reply
|
||||
QEventLoop loop;
|
||||
QTimer::singleShot(200, &loop, SLOT(quit()));
|
||||
QTest::ignoreMessage(QtWarningMsg, "QDBusConnection: couldn't handle call to theSlot, no slot matched");
|
||||
loop.exec();
|
||||
|
||||
// now try to receive the reply
|
||||
|
Loading…
Reference in New Issue
Block a user