diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2012-11-26 10:46:39 -0600 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2012-12-02 15:02:54 +0100 |
commit | e188dd885c961ccda4d75054f8840537526b7d70 (patch) | |
tree | 3242909d6889c41b848f5831e9b7016364410a21 | |
parent | 25d21242e1ba1f188a2cbfc66607c01c204778bd (diff) | |
download | dbus-1-tqt-e188dd885c961ccda4d75054f8840537526b7d70.tar.gz dbus-1-tqt-e188dd885c961ccda4d75054f8840537526b7d70.zip |
Fix intermittent incorrectly set error object on successful dbus call
(cherry picked from commit 76bf393f73c8c7784720b4293ca0abb5e96d30ae)
-rw-r--r-- | tqdbusconnection.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tqdbusconnection.cpp b/tqdbusconnection.cpp index d4449d7..eb2edd5 100644 --- a/tqdbusconnection.cpp +++ b/tqdbusconnection.cpp @@ -29,6 +29,8 @@ #include "tqdbusmessage.h" #include "tqdbusconnection_p.h" +#include "tqdbusmessage_p.h" + QT_STATIC_CONST_IMPL char *TQT_DBusConnection::default_connection_name = "qt_dbus_default_connection"; class TQT_DBusConnectionManager @@ -280,12 +282,23 @@ TQT_DBusMessage TQT_DBusConnection::sendWithReply(const TQT_DBusMessage &message return TQT_DBusMessage::fromDBusMessage(0); DBusMessage *reply = dbus_connection_send_with_reply_and_block(d->connection, msg, -1, &d->error); + if (d->handleError() && error) *error = d->lastError; dbus_message_unref(msg); - return TQT_DBusMessage::fromDBusMessage(reply); + TQT_DBusMessage ret = TQT_DBusMessage::fromDBusMessage(reply); + + // HACK + // Reset the error object if no error was reported by DBus + // This is needed because TQT_DBusMessage::fromDBusMessage sometimes sets the error object even if DBus did not report a fatal error, + // and the dbus_error_is_set() check cannot be moved inside fromDBusMessage() without breaking the API and ABI. + if (!dbus_error_is_set(&d->error)) { + ret.d->error = TQT_DBusError(); + } + + return ret; } void TQT_DBusConnection::flush() const |