diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-06-29 13:20:33 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-07-02 09:43:30 (GMT) |
commit | 8d4657764b0c4362dc25aa79a6e2853b8c98f0ad (patch) | |
tree | 51b61a6b7547168e7e64cd9c3b5574b10a33693b /src/dbus/qdbuspendingcall.cpp | |
parent | 6b0b1a3eefe60dbeed3f56770fb58d487852e45b (diff) | |
download | Qt-8d4657764b0c4362dc25aa79a6e2853b8c98f0ad.zip Qt-8d4657764b0c4362dc25aa79a6e2853b8c98f0ad.tar.gz Qt-8d4657764b0c4362dc25aa79a6e2853b8c98f0ad.tar.bz2 |
Keep creation failure errors for QDBusAbstractInterface.
In case the object creation fails, set isValid to false. This will
prevent any outgoing calls to be made with invalid information. In
that case, lastError will never change either.
This required adding a method to QDBusPendingCall, to be able to
create one such object from an existing QDBusError.
Reviewed-By: Marius Bugge Monsen
Diffstat (limited to 'src/dbus/qdbuspendingcall.cpp')
-rw-r--r-- | src/dbus/qdbuspendingcall.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/dbus/qdbuspendingcall.cpp b/src/dbus/qdbuspendingcall.cpp index 1797ed0..7807543 100644 --- a/src/dbus/qdbuspendingcall.cpp +++ b/src/dbus/qdbuspendingcall.cpp @@ -409,6 +409,42 @@ bool QDBusPendingCall::setReplyCallback(QObject *target, const char *member) } #endif +/*! + Creates a QDBusPendingCall object based on the error condition + \a error. The resulting pending call object will be in the + "finished" state and QDBusPendingReply::isError() will return true. + + \sa fromCompletedCall() +*/ +QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error) +{ + return fromCompletedCall(QDBusMessage::createError(error)); +} + +/*! + Creates a QDBusPendingCall object based on the message \a msg. + The message must be of type QDBusMessage::ErrorMessage or + QDBusMessage::ReplyMessage (that is, a message that is typical + of a completed call). + + This function is useful for code that requires simulating a pending + call, but that has already finished. + + \sa fromError() +*/ +QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg) +{ + QDBusPendingCallPrivate *d = 0; + if (msg.type() == QDBusMessage::ErrorMessage || + msg.type() == QDBusMessage::ReplyMessage) { + d = new QDBusPendingCallPrivate; + d->replyMessage = msg; + d->connection = 0; + } + + return QDBusPendingCall(d); +} + class QDBusPendingCallWatcherPrivate: public QObjectPrivate { |