118 if (!member || !*member) {
120 qWarning(
"QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
121 target ? target->metaObject()->className() :
"(null)",
122 member ? member + 1 :
"(null)",
123 target ? qPrintable(target->objectName()) :
"no name");
128 methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes, errorMsg);
130 QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);
131 methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes, errorMsg);
135 qWarning(
"QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s) "
137 target->metaObject()->className(), member + 1, qPrintable(target->objectName()),
138 qPrintable(errorMsg));
144 int count = metaTypes.size() - 1;
145 if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) {
150 if (metaTypes.at(count) == QDBusMetaTypeId::message())
153 setMetaTypes(count, count ? metaTypes.constData() + 1 :
nullptr);
180 if (replyMessage.type() == QDBusMessage::InvalidMessage)
183 if (replyMessage.type() == QDBusMessage::ErrorMessage)
186 if (expectedReplySignature.isNull())
190 if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {
191 const auto errorMsg =
"Unexpected reply signature: got \"%1\", expected \"%2\""_L1;
192 replyMessage = QDBusMessage::createError(
193 QDBusError::InvalidSignature,
194 errorMsg.arg(replyMessage.signature(), expectedReplySignature));
214 const auto locker = qt_scoped_lock(mutex);
215 if (replyMessage.type() != QDBusMessage::InvalidMessage)
220 loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::reply, &loop,
222 loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::error, &loop,
226 loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
368QDBusError QDBusPendingCall::error()
const
371 const auto locker = qt_scoped_lock(d->mutex);
372 return QDBusError(d->replyMessage);
376 QDBusError err = QDBusError(QDBusError::Disconnected,
377 QDBusUtil::disconnectedErrorMessage());
453QDBusPendingCall QDBusPendingCall::fromCompletedCall(
const QDBusMessage &msg)
455 QDBusPendingCallPrivate *d =
nullptr;
456 if (msg.type() == QDBusMessage::ErrorMessage ||
457 msg.type() == QDBusMessage::ReplyMessage) {
458 d =
new QDBusPendingCallPrivate(QDBusMessage(),
nullptr);
459 d->replyMessage = msg;
460 d->ref.storeRelaxed(1);
463 return QDBusPendingCall(d);
471QDBusPendingCallWatcher::QDBusPendingCallWatcher(
const QDBusPendingCall &call, QObject *parent)
472 : QObject(parent), QDBusPendingCall(call)
475 const auto locker = qt_scoped_lock(d->mutex);
476 if (!d->watcherHelper) {
477 d->watcherHelper =
new QDBusPendingCallWatcherHelper;
478 if (d->replyMessage.type() != QDBusMessage::InvalidMessage) {
480 QMetaObject::invokeMethod(d->watcherHelper,
481 &QDBusPendingCallWatcherHelper::finished,
482 Qt::QueuedConnection);
485 d->watcherHelper->add(
this);