diff options
author | Brett Stottlemyer <bstottle@ford.com> | 2020-07-08 09:38:40 -0400 |
---|---|---|
committer | Sona Kurazyan <sona.kurazyan@qt.io> | 2021-05-27 20:38:54 +0200 |
commit | 175fc3276c5f8981871ca4732602f44bc698436c (patch) | |
tree | e0f98bd0d6e2846d5e06c1963b2529519f8c82e7 /src/remoteobjects/qremoteobjectnode.cpp | |
parent | cab52cc47d5688b64bf8c0d8bf6cafdd4055b540 (diff) |
Move client-side Codec to IoDeviceBase
This is more appropriate than having a separate mapping of connection to
Codec.
Change-Id: I3b54bfb479de04706a3f9563e7a987af91d0282d
Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/remoteobjects/qremoteobjectnode.cpp')
-rw-r--r-- | src/remoteobjects/qremoteobjectnode.cpp | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/remoteobjects/qremoteobjectnode.cpp b/src/remoteobjects/qremoteobjectnode.cpp index b621b47..05444cd 100644 --- a/src/remoteobjects/qremoteobjectnode.cpp +++ b/src/remoteobjects/qremoteobjectnode.cpp @@ -1415,12 +1415,13 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) IoDeviceBase *connection = qobject_cast<IoDeviceBase*>(obj); QRemoteObjectPacketTypeEnum packetType; Q_ASSERT(connection); + auto &codec = connection->d_func()->m_codec; do { if (!connection->read(packetType, rxName)) return; - if (packetType != Handshake && !m_codecs.contains(connection)) { + if (packetType != Handshake && codec == nullptr) { qROPrivWarning() << "Expected Handshake, got " << packetType; setLastError(QRemoteObjectNode::ProtocolMismatch); connection->close(); @@ -1444,12 +1445,12 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) connection->close(); } else { // TODO should have some sort of manager for the codec - m_codecs[connection] = new QRemoteObjectPackets::QDataStreamCodec; + codec = new QRemoteObjectPackets::QDataStreamCodec; } break; case QRemoteObjectPacketTypeEnum::ObjectList: { - codec(connection)->deserializeObjectListPacket(connection->stream(), rxObjects); + codec->deserializeObjectListPacket(connection->stream(), rxObjects); qROPrivDebug() << "newObjects:" << rxObjects; // We need to make sure all of the source objects are in connectedSources before we add connections, // otherwise nested QObjects could fail (we want to acquire children before parents, and the object @@ -1475,7 +1476,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) qROPrivDebug() << "InitPacket-->" << rxName << this; QSharedPointer<QConnectedReplicaImplementation> rep = qSharedPointerCast<QConnectedReplicaImplementation>(replicas.value(rxName).toStrongRef()); //Use m_rxArgs (a QVariantList to hold the properties QVariantList) - codec(connection)->deserializeInitPacket(connection->stream(), rxArgs); + codec->deserializeInitPacket(connection->stream(), rxArgs); if (rep) { handlePointerToQObjectProperties(rep.data(), rxArgs); @@ -1489,7 +1490,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) { qROPrivDebug() << "InitDynamicPacket-->" << rxName << this; const QMetaObject *meta = dynamicTypeManager.addDynamicType(connection, connection->stream()); - codec(connection)->deserializeInitPacket(connection->stream(), rxArgs); + codec->deserializeInitPacket(connection->stream(), rxArgs); QSharedPointer<QConnectedReplicaImplementation> rep = qSharedPointerCast<QConnectedReplicaImplementation>(replicas.value(rxName).toStrongRef()); if (rep) { @@ -1520,7 +1521,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) case QRemoteObjectPacketTypeEnum::PropertyChangePacket: { int propertyIndex; - codec(connection)->deserializePropertyChangePacket(connection->stream(), propertyIndex, rxValue); + codec->deserializePropertyChangePacket(connection->stream(), propertyIndex, rxValue); QSharedPointer<QRemoteObjectReplicaImplementation> rep = qSharedPointerCast<QRemoteObjectReplicaImplementation>(replicas.value(rxName).toStrongRef()); if (rep) { QConnectedReplicaImplementation *connectedRep = nullptr; @@ -1551,7 +1552,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) case QRemoteObjectPacketTypeEnum::InvokePacket: { int call, index, serialId, propertyIndex; - codec(connection)->deserializeInvokePacket(connection->stream(), call, index, rxArgs, serialId, propertyIndex); + codec->deserializeInvokePacket(connection->stream(), call, index, rxArgs, serialId, propertyIndex); QSharedPointer<QRemoteObjectReplicaImplementation> rep = qSharedPointerCast<QRemoteObjectReplicaImplementation>(replicas.value(rxName).toStrongRef()); if (rep) { static QVariant null(QMetaType::fromType<QObject *>(), nullptr); @@ -1586,7 +1587,7 @@ void QRemoteObjectNodePrivate::onClientRead(QObject *obj) case QRemoteObjectPacketTypeEnum::InvokeReplyPacket: { int ackedSerialId; - codec(connection)->deserializeInvokeReplyPacket(connection->stream(), ackedSerialId, rxValue); + codec->deserializeInvokeReplyPacket(connection->stream(), ackedSerialId, rxValue); QSharedPointer<QRemoteObjectReplicaImplementation> rep = qSharedPointerCast<QRemoteObjectReplicaImplementation>(replicas.value(rxName).toStrongRef()); if (rep) { qROPrivDebug() << "Received InvokeReplyPacket ack'ing serial id:" << ackedSerialId; @@ -1751,12 +1752,6 @@ void QRemoteObjectNodePrivate::initialize() QAbstractItemModelSourceAdapter::registerTypes(); } -QRemoteObjectPackets::CodecBase *QRemoteObjectNodePrivate::codec(IoDeviceBase *conn) -{ - Q_ASSERT(m_codecs.contains(conn)); - return m_codecs[conn]; -} - bool QRemoteObjectNodePrivate::checkSignatures(const QByteArray &a, const QByteArray &b) { // if any of a or b is empty it means it's a dynamic ojects or an item model |