diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-03 14:32:25 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-17 18:42:07 +0000 |
commit | 0b67dd7e132d7d618fa538e8c4a275c874543342 (patch) | |
tree | 3c6c7cdf8fbae8c6a7d0d333d96c22d130413980 /src/plugins/qmltooling/qmldbg_server | |
parent | e010b64d38cb8533d779ac0fe8d609f00a6793e7 (diff) |
QmlDebug: Restructure QPacket and QPacketProtocol
We cannot use the same data stream version for the client and server
versions of QPacket and QPacketProtocol should not deal with QPackets
but with simple byte arrays because the underlying QDataStream is hard
to copy.
The new QQmlDebugPacket picks its data stream version from
QQmlDebugConnector now, which adjusts it when connecting. As there can
only ever be one QQmlDebugConnector, we can keep the version static.
The clients need to query the connection for the correct version. We
may connect to several different servers sequentially or we may have a
server running while using a client, and we don't want to confuse the
versions between those.
With this in place, all remaining occurrences of QDataStream are
replaced with QPacket or QQmlDebugPacket.
Change-Id: I3f6ba73fcbfad5e8df917c5feb9308116738a614
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_server')
-rw-r--r-- | src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro | 3 | ||||
-rw-r--r-- | src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp | 22 |
2 files changed, 12 insertions, 13 deletions
diff --git a/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro b/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro index b419f9ca3e..923faa01f3 100644 --- a/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro +++ b/src/plugins/qmltooling/qmldbg_server/qmldbg_server.pro @@ -11,7 +11,8 @@ SOURCES += \ HEADERS += \ $$PWD/qqmldebugserverfactory.h \ $$PWD/../shared/qqmldebugserver.h \ - $$PWD/../shared/qqmldebugserverconnection.h + $$PWD/../shared/qqmldebugserverconnection.h \ + $$PWD/../shared/qqmldebugpacket.h INCLUDEPATH += $$PWD \ $$PWD/../shared diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp index 513aedd568..ba36048802 100644 --- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp +++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp @@ -34,6 +34,7 @@ #include "qqmldebugserver.h" #include "qqmldebugserverfactory.h" #include "qqmldebugserverconnection.h" +#include "qqmldebugpacket.h" #include <private/qqmldebugservice_p.h> #include <private/qqmlengine_p.h> @@ -41,7 +42,6 @@ #include <private/qqmldebugpluginmanager_p.h> #include <private/qqmldebugserviceinterfaces_p.h> #include <private/qpacketprotocol_p.h> -#include <private/qpacket_p.h> #include <QtCore/QAtomicInt> #include <QtCore/QDir> @@ -429,7 +429,7 @@ void QQmlDebugServerImpl::receiveMessage() if (!m_protocol) return; - QPacket in(m_protocol->read().data()); + QQmlDebugPacket in(m_protocol->read()); QString name; @@ -443,17 +443,15 @@ void QQmlDebugServerImpl::receiveMessage() //Get the supported QDataStream version if (!in.atEnd()) { - int dataStreamVersion; - in >> dataStreamVersion; - if (dataStreamVersion > QDataStream().version()) - dataStreamVersion = QDataStream().version(); - QPacket::setDataStreamVersion(dataStreamVersion); + in >> s_dataStreamVersion; + if (s_dataStreamVersion > QDataStream::Qt_DefaultCompiledVersion) + s_dataStreamVersion = QDataStream::Qt_DefaultCompiledVersion; } // Send the hello answer immediately, since it needs to arrive before // the plugins below start sending messages. - QPacket out; + QQmlDebugPacket out; QStringList pluginNames; QList<float> pluginVersions; const int count = m_plugins.count(); @@ -466,9 +464,9 @@ void QQmlDebugServerImpl::receiveMessage() } out << QString(QStringLiteral("QDeclarativeDebugClient")) << 0 << protocolVersion - << pluginNames << pluginVersions << QPacket::dataStreamVersion(); + << pluginNames << pluginVersions << dataStreamVersion(); - m_protocol->send(out); + m_protocol->send(out.data()); m_connection->flush(); QMutexLocker helloLock(&m_helloMutex); @@ -650,9 +648,9 @@ bool QQmlDebugServerImpl::canSendMessage(const QString &name) void QQmlDebugServerImpl::doSendMessage(const QString &name, const QByteArray &message) { - QPacket out; + QQmlDebugPacket out; out << name << message; - m_protocol->send(out); + m_protocol->send(out.data()); } void QQmlDebugServerImpl::sendMessage(const QString &name, const QByteArray &message) |