aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmldebug
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-03 14:32:25 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-17 18:42:07 +0000
commit0b67dd7e132d7d618fa538e8c4a275c874543342 (patch)
tree3c6c7cdf8fbae8c6a7d0d333d96c22d130413980 /src/qmldebug
parente010b64d38cb8533d779ac0fe8d609f00a6793e7 (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/qmldebug')
-rw-r--r--src/qmldebug/qqmldebugclient.cpp6
-rw-r--r--src/qmldebug/qqmldebugclient_p.h2
-rw-r--r--src/qmldebug/qqmldebugconnection.cpp37
-rw-r--r--src/qmldebug/qqmldebugconnection_p.h4
-rw-r--r--src/qmldebug/qqmlprofilerclient.cpp13
-rw-r--r--src/qmldebug/qqmlprofilerclient_p.h3
6 files changed, 37 insertions, 28 deletions
diff --git a/src/qmldebug/qqmldebugclient.cpp b/src/qmldebug/qqmldebugclient.cpp
index 6f27cede4b..b5d1130f88 100644
--- a/src/qmldebug/qqmldebugclient.cpp
+++ b/src/qmldebug/qqmldebugclient.cpp
@@ -105,6 +105,12 @@ void QQmlDebugClient::sendMessage(const QByteArray &message)
d->connection->sendMessage(d->name, message);
}
+const QQmlDebugConnection *QQmlDebugClient::connection() const
+{
+ Q_D(const QQmlDebugClient);
+ return d->connection;
+}
+
void QQmlDebugClient::stateChanged(QQmlDebugClient::State state)
{
Q_UNUSED(state);
diff --git a/src/qmldebug/qqmldebugclient_p.h b/src/qmldebug/qqmldebugclient_p.h
index 997e6879cf..8e8330f317 100644
--- a/src/qmldebug/qqmldebugclient_p.h
+++ b/src/qmldebug/qqmldebugclient_p.h
@@ -68,6 +68,8 @@ public:
State state() const;
void sendMessage(const QByteArray &message);
+ const QQmlDebugConnection *connection() const;
+
protected:
QQmlDebugClient(QQmlDebugClientPrivate &dd);
diff --git a/src/qmldebug/qqmldebugconnection.cpp b/src/qmldebug/qqmldebugconnection.cpp
index b4ced0580e..e8650ebbff 100644
--- a/src/qmldebug/qqmldebugconnection.cpp
+++ b/src/qmldebug/qqmldebugconnection.cpp
@@ -64,7 +64,8 @@ public:
QTimer handshakeTimer;
bool gotHello;
- int dataStreamVersion;
+ int currentDataStreamVersion;
+ int maximumDataStreamVersion;
QHash <QString, float> serverPlugins;
QHash<QString, QQmlDebugClient *> plugins;
QStringList removedPlugins;
@@ -75,7 +76,9 @@ public:
};
QQmlDebugConnectionPrivate::QQmlDebugConnectionPrivate() :
- protocol(0), device(0), server(0), gotHello(false), dataStreamVersion(QDataStream::Qt_5_0)
+ protocol(0), device(0), server(0), gotHello(false),
+ currentDataStreamVersion(QDataStream::Qt_4_7),
+ maximumDataStreamVersion(QDataStream::Qt_DefaultCompiledVersion)
{
handshakeTimer.setSingleShot(true);
handshakeTimer.setInterval(3000);
@@ -87,18 +90,18 @@ void QQmlDebugConnectionPrivate::advertisePlugins()
if (!q->isConnected())
return;
- QPacket pack;
+ QPacket pack(currentDataStreamVersion);
pack << serverId << 1 << plugins.keys();
- protocol->send(pack);
+ protocol->send(pack.data());
flush();
}
void QQmlDebugConnection::socketConnected()
{
Q_D(QQmlDebugConnection);
- QPacket pack;
- pack << serverId << 0 << protocolVersion << d->plugins.keys() << d->dataStreamVersion;
- d->protocol->send(pack);
+ QPacket pack(d->currentDataStreamVersion);
+ pack << serverId << 0 << protocolVersion << d->plugins.keys() << d->maximumDataStreamVersion;
+ d->protocol->send(pack.data());
d->flush();
}
@@ -112,7 +115,7 @@ void QQmlDebugConnection::protocolReadyRead()
{
Q_D(QQmlDebugConnection);
if (!d->gotHello) {
- QPacket pack = d->protocol->read();
+ QPacket pack(d->currentDataStreamVersion, d->protocol->read());
QString name;
pack >> name;
@@ -140,7 +143,7 @@ void QQmlDebugConnection::protocolReadyRead()
d->serverPlugins.insert(pluginNames.at(i), pluginVersion);
}
- pack >> d->dataStreamVersion;
+ pack >> d->currentDataStreamVersion;
validHello = true;
}
}
@@ -167,7 +170,7 @@ void QQmlDebugConnection::protocolReadyRead()
}
while (d->protocol->packetsAvailable()) {
- QPacket pack = d->protocol->read();
+ QPacket pack(d->currentDataStreamVersion, d->protocol->read());
QString name;
pack >> name;
@@ -252,16 +255,16 @@ QQmlDebugConnection::~QQmlDebugConnection()
iter.value()->stateChanged(QQmlDebugClient::NotConnected);
}
-void QQmlDebugConnection::setDataStreamVersion(int dataStreamVersion)
+int QQmlDebugConnection::currentDataStreamVersion() const
{
- Q_D(QQmlDebugConnection);
- d->dataStreamVersion = dataStreamVersion;
+ Q_D(const QQmlDebugConnection);
+ return d->currentDataStreamVersion;
}
-int QQmlDebugConnection::dataStreamVersion()
+void QQmlDebugConnection::setMaximumDataStreamVersion(int maximumVersion)
{
Q_D(QQmlDebugConnection);
- return d->dataStreamVersion;
+ d->maximumDataStreamVersion = maximumVersion;
}
bool QQmlDebugConnection::isConnected() const
@@ -345,9 +348,9 @@ bool QQmlDebugConnection::sendMessage(const QString &name, const QByteArray &mes
if (!isConnected() || !d->serverPlugins.contains(name))
return false;
- QPacket pack;
+ QPacket pack(d->currentDataStreamVersion);
pack << name << message;
- d->protocol->send(pack);
+ d->protocol->send(pack.data());
d->flush();
return true;
diff --git a/src/qmldebug/qqmldebugconnection_p.h b/src/qmldebug/qqmldebugconnection_p.h
index b3845b95a0..31a4d7167a 100644
--- a/src/qmldebug/qqmldebugconnection_p.h
+++ b/src/qmldebug/qqmldebugconnection_p.h
@@ -63,8 +63,8 @@ public:
void connectToHost(const QString &hostName, quint16 port);
void startLocalServer(const QString &fileName);
- void setDataStreamVersion(int dataStreamVersion);
- int dataStreamVersion();
+ int currentDataStreamVersion() const;
+ void setMaximumDataStreamVersion(int maximumVersion);
bool isConnected() const;
void close();
diff --git a/src/qmldebug/qqmlprofilerclient.cpp b/src/qmldebug/qqmlprofilerclient.cpp
index 1ac0ba9095..f38884c309 100644
--- a/src/qmldebug/qqmlprofilerclient.cpp
+++ b/src/qmldebug/qqmlprofilerclient.cpp
@@ -32,8 +32,7 @@
****************************************************************************/
#include "qqmlprofilerclient_p_p.h"
-
-#include <QtCore/qdatastream.h>
+#include "qqmldebugconnection_p.h"
QT_BEGIN_NAMESPACE
@@ -63,10 +62,9 @@ void QQmlProfilerClient::sendRecordingStatus(bool record, int engineId, quint32
{
Q_D(const QQmlProfilerClient);
- QByteArray ba;
- QDataStream stream(&ba, QIODevice::WriteOnly);
+ QPacket stream(d->connection->currentDataStreamVersion());
stream << record << engineId << d->features << flushInterval;
- sendMessage(ba);
+ sendMessage(stream.data());
}
void QQmlProfilerClient::traceStarted(qint64 time, int engineId)
@@ -172,7 +170,7 @@ void QQmlProfilerClient::unknownEvent(QQmlProfilerDefinitions::Message messageTy
Q_UNUSED(detailType);
}
-void QQmlProfilerClient::unknownData(QDataStream &stream)
+void QQmlProfilerClient::unknownData(QPacket &stream)
{
Q_UNUSED(stream);
}
@@ -202,8 +200,7 @@ void QQmlProfilerClient::messageReceived(const QByteArray &data)
{
Q_D(const QQmlProfilerClient);
- QByteArray rwData = data;
- QDataStream stream(&rwData, QIODevice::ReadOnly);
+ QPacket stream(d->connection->currentDataStreamVersion(), data);
// Force all the 1 << <FLAG> expressions to be done in 64 bit, to silence some warnings
const quint64 one = static_cast<quint64>(1);
diff --git a/src/qmldebug/qqmlprofilerclient_p.h b/src/qmldebug/qqmlprofilerclient_p.h
index f00fbd873a..0513bef608 100644
--- a/src/qmldebug/qqmlprofilerclient_p.h
+++ b/src/qmldebug/qqmlprofilerclient_p.h
@@ -37,6 +37,7 @@
#include "qqmldebugclient_p.h"
#include "qqmleventlocation_p.h"
#include <private/qqmlprofilerdefinitions_p.h>
+#include <private/qpacket_p.h>
//
// W A R N I N G
@@ -99,7 +100,7 @@ private:
virtual void unknownEvent(QQmlProfilerDefinitions::Message messageType, qint64 time,
int detailType);
- virtual void unknownData(QDataStream &stream);
+ virtual void unknownData(QPacket &stream);
};
QT_END_NAMESPACE