diff options
-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 1af78f5..a1a9b56 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 1c921aa..c2c87ed 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 4a55c64..e2f7f26 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; |