diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index 99c1687661..3431992eac 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -316,7 +316,8 @@ public: public: // static methods - static int findSlot(QObject *obj, const QByteArray &normalizedName, QList ¶ms); + static int findSlot(QObject *obj, const QByteArray &normalizedName, QList ¶ms, + QString &errorMsg); static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key, const QString &service, const QString &path, const QString &interface, const QString &name, diff --git a/src/dbus/qdbusintegrator.cpp b/src/dbus/qdbusintegrator.cpp index 8b190b8e5f..09f29f9556 100644 --- a/src/dbus/qdbusintegrator.cpp +++ b/src/dbus/qdbusintegrator.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -50,6 +50,8 @@ QT_IMPL_METATYPE_EXTERN(QDBusSlotCache) // used with dbus_server_allocate_data_slot static dbus_int32_t server_slot = -1; +Q_LOGGING_CATEGORY(dbusIntegration, "qt.dbus.integration", QtWarningMsg) + Q_CONSTINIT static QBasicAtomicInt isDebugging = Q_BASIC_ATOMIC_INITIALIZER(-1); #define qDBusDebug if (::isDebugging.loadRelaxed() == 0); else qDebug @@ -860,6 +862,9 @@ bool QDBusConnectionPrivate::activateCall(QObject* object, int flags, const QDBu slotData.metaTypes.clear(); slotCache.hash.insert(cacheKey, slotData); object->setProperty(cachePropertyName, QVariant::fromValue(slotCache)); + + qCWarning(dbusIntegration).nospace() << "Could not find slot " << mo->className() + << "::" << memberName.constData(); return false; } } @@ -1288,16 +1293,16 @@ void QDBusConnectionPrivate::serviceOwnerChangedNoLock(const QString &name, } int QDBusConnectionPrivate::findSlot(QObject *obj, const QByteArray &normalizedName, - QList ¶ms) + QList ¶ms, QString &errorMsg) { + errorMsg.clear(); int midx = obj->metaObject()->indexOfMethod(normalizedName); if (midx == -1) return -1; - QString errorMsg; int inputCount = qDBusParametersForMethod(obj->metaObject()->method(midx), params, errorMsg); - if ( inputCount == -1 || inputCount + 1 != params.size() ) - return -1; // failed to parse or invalid arguments or output arguments + if (inputCount == -1 || inputCount + 1 != params.size()) + return -1; return midx; } @@ -1310,10 +1315,11 @@ bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hoo bool buildSignature) { QByteArray normalizedName = signal + 1; - hook.midx = findSlot(receiver, signal + 1, hook.params); + QString errorMsg; + hook.midx = findSlot(receiver, signal + 1, hook.params, errorMsg); if (hook.midx == -1) { normalizedName = QMetaObject::normalizedSignature(signal + 1); - hook.midx = findSlot(receiver, normalizedName, hook.params); + hook.midx = findSlot(receiver, normalizedName, hook.params, errorMsg); } if (hook.midx < minMIdx) { return false; @@ -2210,8 +2216,11 @@ bool QDBusConnectionPrivate::connectSignal(const QString &service, QString key; hook.signature = signature; - if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false)) + if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, + false)) { + qCWarning(dbusIntegration) << "Could not connect" << interface << "to" << slot + 1; return false; // don't connect + } Q_ASSERT(thread() != QThread::currentThread()); return emit signalNeedsConnecting(key, hook); @@ -2300,8 +2309,11 @@ bool QDBusConnectionPrivate::disconnectSignal(const QString &service, name2.detach(); hook.signature = signature; - if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false)) + if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, + false)) { + qCWarning(dbusIntegration) << "Could not disconnect" << interface << "to" << slot + 1; return false; // don't disconnect + } Q_ASSERT(thread() != QThread::currentThread()); return emit signalNeedsDisconnecting(key, hook); @@ -2428,8 +2440,10 @@ void QDBusConnectionPrivate::connectRelay(const QString &service, sig.append(QSIGNAL_CODE + '0'); sig.append(signal.methodSignature()); if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig, - QDBusAbstractInterface::staticMetaObject.methodCount(), true)) + QDBusAbstractInterface::staticMetaObject.methodCount(), true)) { + qCWarning(dbusIntegration) << "Could not connect" << interface << "to" << signal.name(); return; // don't connect + } Q_ASSERT(thread() != QThread::currentThread()); emit signalNeedsConnecting(key, hook); @@ -2449,8 +2463,11 @@ void QDBusConnectionPrivate::disconnectRelay(const QString &service, sig.append(QSIGNAL_CODE + '0'); sig.append(signal.methodSignature()); if (!prepareHook(hook, key, service, path, interface, QString(), ArgMatchRules(), receiver, sig, - QDBusAbstractInterface::staticMetaObject.methodCount(), true)) + QDBusAbstractInterface::staticMetaObject.methodCount(), true)) { + qCWarning(dbusIntegration) + << "Could not disconnect" << interface << "to" << signal.methodSignature(); return; // don't disconnect + } Q_ASSERT(thread() != QThread::currentThread()); emit signalNeedsDisconnecting(key, hook); diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 7674dd10f2..ff5dfc8967 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -123,16 +123,18 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb return false; } - methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes); + QString errorMsg; + methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes, errorMsg); if (methodIdx == -1) { QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1); - methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes); + methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes, errorMsg); } if (methodIdx == -1) { // would not be able to deliver a reply - qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)", - target->metaObject()->className(), - member + 1, qPrintable(target->objectName())); + qWarning("QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s) " + "because %s", + target->metaObject()->className(), member + 1, qPrintable(target->objectName()), + qPrintable(errorMsg)); return false; }