From 76bf393f73c8c7784720b4293ca0abb5e96d30ae Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 26 Nov 2012 10:46:39 -0600 Subject: [PATCH] Fix intermittent incorrectly set error object on successful dbus call --- tqdbusconnection.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tqdbusconnection.cpp b/tqdbusconnection.cpp index a755610..d185e36 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