diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2012-03-12 12:41:24 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-12 15:23:13 +0100 |
commit | d5a85940f785459d7b982d5fdf59a9fd18825092 (patch) | |
tree | ce288a5c54c35afac897cab9e3404df157ac5e43 /src | |
parent | 6c2695d677215868447790297c1401628eabc47e (diff) |
QDBusError: add assignment operator from QDBusMessage
There's an implicit constructor for this conversion,
so there should be an assignment operator, too,
as an optimisation.
Change-Id: I1d1646cbafdea5a4f80b11b011a8940b65a9fb9f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/dbus/qdbuserror.cpp | 18 | ||||
-rw-r--r-- | src/dbus/qdbuserror.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/dbus/qdbuserror.cpp b/src/dbus/qdbuserror.cpp index 9db279e005..81afe6c483 100644 --- a/src/dbus/qdbuserror.cpp +++ b/src/dbus/qdbuserror.cpp @@ -303,6 +303,24 @@ QDBusError &QDBusError::operator=(const QDBusError &other) } /*! + \internal + Assignment operator from a QDBusMessage +*/ +QDBusError &QDBusError::operator=(const QDBusMessage &qdmsg) +{ + if (qdmsg.type() == QDBusMessage::ErrorMessage) { + code = ::get(qdmsg.errorName().toUtf8().constData()); + nm = qdmsg.errorName(); + msg = qdmsg.errorMessage(); + } else { + code =NoError; + nm.clear(); + msg.clear(); + } + return *this; +} + +/*! Returns this error's ErrorType. \sa ErrorType diff --git a/src/dbus/qdbuserror.h b/src/dbus/qdbuserror.h index ed0bfaad9b..3057f88715 100644 --- a/src/dbus/qdbuserror.h +++ b/src/dbus/qdbuserror.h @@ -98,6 +98,7 @@ public: QDBusError(ErrorType error, const QString &message); QDBusError(const QDBusError &other); QDBusError &operator=(const QDBusError &other); + QDBusError &operator=(const QDBusMessage &msg); ErrorType type() const; QString name() const; |