Fix failure to report DBUS non-fatal errors

pull/2/head
Timothy Pearson 12 years ago
parent 6dd1ccf1d3
commit cad05aaaa1

@ -290,14 +290,9 @@ TQT_DBusMessage TQT_DBusConnection::sendWithReply(const TQT_DBusMessage &message
TQT_DBusMessage ret = TQT_DBusMessage::fromDBusMessage(reply); TQT_DBusMessage ret = TQT_DBusMessage::fromDBusMessage(reply);
// HACK bool dbus_error_set = dbus_error_is_set(&d->error);
// Reset the error object if no error was reported by DBus ret.d->error.setDBUSError(dbus_error_set);
// This is needed because TQT_DBusMessage::fromDBusMessage sometimes sets the error object even if DBus did not report a fatal error, if (error) error->setDBUSError(dbus_error_set);
// 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();
}
return ret; return ret;
} }

@ -113,11 +113,11 @@ static TQT_DBusError::ErrorType qDBusErrorTypeForName(const TQString& name)
return TQT_DBusError::UserDefined; 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)) if (!error || !dbus_error_is_set(error))
return; return;
@ -129,7 +129,7 @@ TQT_DBusError::TQT_DBusError(const DBusError *error) : errorType(InvalidError)
} }
TQT_DBusError::TQT_DBusError(const TQString& error, const TQString& message) 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); errorType = qDBusErrorTypeForName(nm);
} }
@ -140,7 +140,7 @@ bool TQT_DBusError::isValid() const
} }
TQT_DBusError::TQT_DBusError(ErrorType type, const TQString& message) TQT_DBusError::TQT_DBusError(ErrorType type, const TQString& message)
: errorType(type), msg(message) : errorType(type), m_dbusErrorSet(false), msg(message)
{ {
nm = qDBusErrorNameForType(type); nm = qDBusErrorNameForType(type);
} }

@ -306,6 +306,20 @@ public:
*/ */
inline ErrorType type() const { return errorType; } 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 * @brief Returns whether the error object is valid
* *
@ -444,6 +458,7 @@ public:
private: private:
ErrorType errorType; ErrorType errorType;
mutable bool m_dbusErrorSet;
TQString nm, msg; TQString nm, msg;

Loading…
Cancel
Save