119 if (!member || !*member) {
121 qWarning(
"QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s)",
122 target ? target->metaObject()->className() :
"(null)",
123 member ? member + 1 :
"(null)",
124 target ? qPrintable(target->objectName()) :
"no name");
129 methodIdx = QDBusConnectionPrivate::findSlot(target, member + 1, metaTypes, errorMsg);
131 QByteArray normalizedName = QMetaObject::normalizedSignature(member + 1);
132 methodIdx = QDBusConnectionPrivate::findSlot(target, normalizedName, metaTypes, errorMsg);
136 qWarning(
"QDBusPendingCall::setReplyCallback: error: cannot deliver a reply to %s::%s (%s) "
138 target->metaObject()->className(), member + 1, qPrintable(target->objectName()),
139 qPrintable(errorMsg));
145 int count = metaTypes.size() - 1;
146 if (count == 1 && metaTypes.at(1) == QDBusMetaTypeId::message()) {
151 if (metaTypes.at(count) == QDBusMetaTypeId::message())
154 setMetaTypes(count, count ? metaTypes.constData() + 1 :
nullptr);
181 if (replyMessage.type() == QDBusMessage::InvalidMessage)
184 if (replyMessage.type() == QDBusMessage::ErrorMessage)
187 if (expectedReplySignature.isNull())
191 if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {
192 const auto errorMsg =
"Unexpected reply signature: got \"%1\", expected \"%2\""_L1;
193 replyMessage = QDBusMessage::createError(
194 QDBusError::InvalidSignature,
195 errorMsg.arg(replyMessage.signature(), expectedReplySignature));
215 const auto locker = qt_scoped_lock(mutex);
216 if (replyMessage.type() != QDBusMessage::InvalidMessage)
221 loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::reply, &loop,
223 loop.connect(watcherHelper, &QDBusPendingCallWatcherHelper::error, &loop,
227 loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
391QDBusError QDBusPendingCall::error()
const
394 const auto locker = qt_scoped_lock(d->mutex);
395 return QDBusError(d->replyMessage);
399 QDBusError err = QDBusError(QDBusError::Disconnected,
400 QDBusUtil::disconnectedErrorMessage());
476QDBusPendingCall QDBusPendingCall::fromCompletedCall(
const QDBusMessage &msg)
478 QDBusPendingCallPrivate *d =
nullptr;
479 if (msg.type() == QDBusMessage::ErrorMessage ||
480 msg.type() == QDBusMessage::ReplyMessage) {
481 d =
new QDBusPendingCallPrivate(QDBusMessage(),
nullptr);
482 d->replyMessage = msg;
483 d->ref.storeRelaxed(1);
486 return QDBusPendingCall(d);
494QDBusPendingCallWatcher::QDBusPendingCallWatcher(
const QDBusPendingCall &call, QObject *parent)
495 : QObject(parent), QDBusPendingCall(call)
498 const auto locker = qt_scoped_lock(d->mutex);
499 if (!d->watcherHelper) {
500 d->watcherHelper =
new QDBusPendingCallWatcherHelper;
501 if (d->replyMessage.type() != QDBusMessage::InvalidMessage) {
503 QMetaObject::invokeMethod(d->watcherHelper,
504 &QDBusPendingCallWatcherHelper::finished,
505 Qt::QueuedConnection);
508 d->watcherHelper->add(
this);