diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2013-04-15 12:40:24 -0500 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2015-12-17 21:45:00 +0100 |
commit | b3511a6ec42b315dd6b784cf45d836cec0214cbb (patch) | |
tree | e15256f1622f328aadb7c9fa3730e445ad1c28d5 | |
parent | 995a573a2ea7c6e371b6698a91414a18a447975d (diff) | |
download | dbus-1-tqt-b3511a6ec42b315dd6b784cf45d836cec0214cbb.tar.gz dbus-1-tqt-b3511a6ec42b315dd6b784cf45d836cec0214cbb.zip |
Fix failure to report DBUS non-fatal errors
(cherry picked from commit cad05aaaa116db2e7a326eca73d9167f256b187d)
-rw-r--r-- | tqdbusconnection.cpp | 11 | ||||
-rw-r--r-- | tqdbuserror.cpp | 8 | ||||
-rw-r--r-- | tqdbuserror.h | 15 |
3 files changed, 22 insertions, 12 deletions
diff --git a/tqdbusconnection.cpp b/tqdbusconnection.cpp index 3895214..a62735e 100644 --- a/tqdbusconnection.cpp +++ b/tqdbusconnection.cpp @@ -290,14 +290,9 @@ TQT_DBusMessage TQT_DBusConnection::sendWithReply(const TQT_DBusMessage &message 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(); - if (error) *error = TQT_DBusError(); - } + bool dbus_error_set = dbus_error_is_set(&d->error); + ret.d->error.setDBUSError(dbus_error_set); + if (error) error->setDBUSError(dbus_error_set); return ret; } diff --git a/tqdbuserror.cpp b/tqdbuserror.cpp index 5243436..d0b1eb9 100644 --- a/tqdbuserror.cpp +++ b/tqdbuserror.cpp @@ -113,11 +113,11 @@ static TQT_DBusError::ErrorType qDBusErrorTypeForName(const TQString& name) return TQT_DBusError::UserDefined; } -TQT_DBusError::TQT_DBusError() : errorType(InvalidError) +TQT_DBusError::TQT_DBusError() : errorType(InvalidError), m_dbusErrorSet(false) { } -TQT_DBusError::TQT_DBusError(const DBusError *error) : errorType(InvalidError) +TQT_DBusError::TQT_DBusError(const DBusError *error) : errorType(InvalidError), m_dbusErrorSet(false) { if (!error || !dbus_error_is_set(error)) return; @@ -129,7 +129,7 @@ TQT_DBusError::TQT_DBusError(const DBusError *error) : errorType(InvalidError) } TQT_DBusError::TQT_DBusError(const TQString& error, const TQString& message) - : errorType(UserDefined), nm(error), msg(message) + : errorType(UserDefined), m_dbusErrorSet(false), nm(error), msg(message) { errorType = qDBusErrorTypeForName(nm); } @@ -140,7 +140,7 @@ bool TQT_DBusError::isValid() const } TQT_DBusError::TQT_DBusError(ErrorType type, const TQString& message) - : errorType(type), msg(message) + : errorType(type), m_dbusErrorSet(false), msg(message) { nm = qDBusErrorNameForType(type); } diff --git a/tqdbuserror.h b/tqdbuserror.h index d3e5cce..ff11ffb 100644 --- a/tqdbuserror.h +++ b/tqdbuserror.h @@ -307,6 +307,20 @@ public: inline ErrorType type() const { return errorType; } /** + * @brief Returns whether the error was caused by DBUS itself + * + * A TQT_DBusError is considered valid if both name and message are set. + * + * @return @c true if dbus_error_is_set was true after DBUS call completion + */ + inline bool dbusErrorSet() const { return m_dbusErrorSet; } + + /** + * @internal + */ + inline void setDBUSError(bool err) const { m_dbusErrorSet = err; } + + /** * @brief Returns whether the error object is valid * * A TQT_DBusError is considered valid if both name and message are set. @@ -444,6 +458,7 @@ public: private: ErrorType errorType; + mutable bool m_dbusErrorSet; TQString nm, msg; |