QDBusArgumentPrivate: Specify direction as argument to constructor
This avoids having direction member uninitialized by mistake. Make the member variable const as it is never modified. While at it, make Direction and enum class. Change-Id: I53814ae9e1d6bcf786433674619145a1ee61e063 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
946992b9b0
commit
bfdefa81f8
|
|
@ -71,7 +71,7 @@ bool QDBusArgumentPrivate::checkWrite(QDBusArgumentPrivate *&d)
|
|||
{
|
||||
if (!d)
|
||||
return false;
|
||||
if (d->direction == Marshalling) {
|
||||
if (d->direction == Direction::Marshalling) {
|
||||
if (!d->marshaller()->ok)
|
||||
return false;
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ bool QDBusArgumentPrivate::checkRead(QDBusArgumentPrivate *d)
|
|||
{
|
||||
if (!d)
|
||||
return false;
|
||||
if (d->direction == Demarshalling)
|
||||
if (d->direction == Direction::Demarshalling)
|
||||
return true;
|
||||
|
||||
#ifdef QT_DEBUG
|
||||
|
|
@ -537,7 +537,7 @@ QString QDBusArgument::currentSignature() const
|
|||
{
|
||||
if (!d)
|
||||
return QString();
|
||||
if (d->direction == QDBusArgumentPrivate::Demarshalling)
|
||||
if (d->direction == QDBusArgumentPrivate::Direction::Demarshalling)
|
||||
return d->demarshaller()->currentSignature();
|
||||
else
|
||||
return d->marshaller()->currentSignature();
|
||||
|
|
@ -556,7 +556,7 @@ QDBusArgument::ElementType QDBusArgument::currentType() const
|
|||
{
|
||||
if (!d)
|
||||
return UnknownType;
|
||||
if (d->direction == QDBusArgumentPrivate::Demarshalling)
|
||||
if (d->direction == QDBusArgumentPrivate::Direction::Demarshalling)
|
||||
return d->demarshaller()->currentType();
|
||||
return UnknownType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,8 +35,11 @@ class QDBusDemarshaller;
|
|||
class QDBusArgumentPrivate
|
||||
{
|
||||
public:
|
||||
explicit QDBusArgumentPrivate(QDBusConnection::ConnectionCapabilities flags = {})
|
||||
: capabilities(flags)
|
||||
enum class Direction { Marshalling, Demarshalling };
|
||||
|
||||
explicit QDBusArgumentPrivate(Direction direction,
|
||||
QDBusConnection::ConnectionCapabilities flags = {})
|
||||
: capabilities(flags), direction(direction)
|
||||
{
|
||||
}
|
||||
virtual ~QDBusArgumentPrivate();
|
||||
|
|
@ -60,19 +63,15 @@ public:
|
|||
DBusMessage *message = nullptr;
|
||||
QAtomicInt ref = 1;
|
||||
QDBusConnection::ConnectionCapabilities capabilities;
|
||||
enum Direction {
|
||||
Marshalling,
|
||||
Demarshalling
|
||||
} direction;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
class QDBusMarshaller: public QDBusArgumentPrivate
|
||||
{
|
||||
public:
|
||||
explicit QDBusMarshaller(QDBusConnection::ConnectionCapabilities flags = {})
|
||||
: QDBusArgumentPrivate(flags)
|
||||
: QDBusArgumentPrivate(Direction::Marshalling, flags)
|
||||
{
|
||||
direction = Marshalling;
|
||||
}
|
||||
~QDBusMarshaller();
|
||||
|
||||
|
|
@ -130,9 +129,8 @@ class QDBusDemarshaller: public QDBusArgumentPrivate
|
|||
{
|
||||
public:
|
||||
explicit QDBusDemarshaller(QDBusConnection::ConnectionCapabilities flags = {})
|
||||
: QDBusArgumentPrivate(flags)
|
||||
: QDBusArgumentPrivate(Direction::Demarshalling, flags)
|
||||
{
|
||||
direction = Demarshalling;
|
||||
}
|
||||
~QDBusDemarshaller();
|
||||
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
|
|||
QDBusDemarshaller demarshaller(capabilities);
|
||||
demarshaller.message = q_dbus_message_ref(d->message);
|
||||
|
||||
if (d->direction == Demarshalling) {
|
||||
if (d->direction == Direction::Demarshalling) {
|
||||
// it's demarshalling; just copy
|
||||
demarshaller.iterator = static_cast<QDBusDemarshaller *>(d)->iterator;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue