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>
This commit is contained in:
Marc Mutz 2012-03-12 12:41:24 +01:00 committed by Qt by Nokia
parent 6c2695d677
commit d5a85940f7
2 changed files with 19 additions and 0 deletions

View File

@ -302,6 +302,24 @@ QDBusError &QDBusError::operator=(const QDBusError &other)
return *this;
}
/*!
\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.

View File

@ -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;