From: Aurindam Jana Date: Mon, 23 Apr 2012 07:23:23 +0000 (+0200) Subject: QmlDebugging: Exchange supported QDataStream versions X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=7f7cd79e29e634ddff55fe18b122ac85c5cfe4a0;p=konrad%2Fqtdeclarative.git QmlDebugging: Exchange supported QDataStream versions Since the client and service needs to pack/unpack datastreams, they need to encode/decode using the lowest common QDataStream version. Change-Id: I3b4886fece59b24950ba618da07a0fefd41a5637 Reviewed-by: Kai Koehne --- diff --git a/src/plugins/qmltooling/shared/abstractviewinspector.cpp b/src/plugins/qmltooling/shared/abstractviewinspector.cpp index 5784f64..02a85e2 100644 --- a/src/plugins/qmltooling/shared/abstractviewinspector.cpp +++ b/src/plugins/qmltooling/shared/abstractviewinspector.cpp @@ -268,7 +268,7 @@ bool AbstractViewInspector::touchEvent(QTouchEvent *event) void AbstractViewInspector::handleMessage(const QByteArray &message) { bool success = true; - QDataStream ds(message); + QQmlDebugStream ds(message); QByteArray type; ds >> type; @@ -342,7 +342,7 @@ void AbstractViewInspector::handleMessage(const QByteArray &message) } QByteArray response; - QDataStream rs(&response, QIODevice::WriteOnly); + QQmlDebugStream rs(&response, QIODevice::WriteOnly); rs << QByteArray(RESPONSE) << requestId << success; m_debugService->sendMessage(response); } @@ -350,7 +350,7 @@ void AbstractViewInspector::handleMessage(const QByteArray &message) void AbstractViewInspector::sendCurrentObjects(const QList &objects) { QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); + QQmlDebugStream ds(&message, QIODevice::WriteOnly); ds << QByteArray(EVENT) << m_eventId++ << QByteArray(SELECT); diff --git a/src/qml/debugger/qdebugmessageservice.cpp b/src/qml/debugger/qdebugmessageservice.cpp index bcd7985..d44bbf9 100644 --- a/src/qml/debugger/qdebugmessageservice.cpp +++ b/src/qml/debugger/qdebugmessageservice.cpp @@ -99,7 +99,7 @@ void QDebugMessageService::sendDebugMessage(QtMsgType type, //We just eavesdrop and forward the messages to a port //only if a client is connected to it. QByteArray message; - QDataStream ws(&message, QIODevice::WriteOnly); + QQmlDebugStream ws(&message, QIODevice::WriteOnly); ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8(); ws << QString::fromLatin1(ctxt.file).toUtf8(); ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8(); diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp index b247e43..ae9b103 100644 --- a/src/qml/debugger/qqmldebugserver.cpp +++ b/src/qml/debugger/qqmldebugserver.cpp @@ -61,11 +61,11 @@ QT_BEGIN_NAMESPACE handshake: 1. Client sends - "QDeclarativeDebugServer" 0 version pluginNames + "QDeclarativeDebugServer" 0 version pluginNames [QDataStream version] version: an int representing the highest protocol version the client knows pluginNames: plugins available on client side 2. Server sends - "QDeclarativeDebugClient" 0 version pluginNames pluginVersions + "QDeclarativeDebugClient" 0 version pluginNames pluginVersions [QDataStream version] version: an int representing the highest protocol version the client & server know pluginNames: plugins available on server side. plugins both in the client and server message are enabled. client plugin advertisement @@ -79,6 +79,7 @@ QT_BEGIN_NAMESPACE */ const int protocolVersion = 1; +int QQmlDebugServer::s_dataStreamVersion = QDataStream::Qt_4_7; // print detailed information about loading of plugins DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) @@ -158,7 +159,7 @@ void QQmlDebugServerPrivate::advertisePlugins() QByteArray message; { - QDataStream out(&message, QIODevice::WriteOnly); + QQmlDebugStream out(&message, QIODevice::WriteOnly); QStringList pluginNames; QList pluginVersions; foreach (QQmlDebugService *service, plugins.values()) { @@ -384,7 +385,7 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) Q_D(QQmlDebugServer); - QDataStream in(message); + QQmlDebugStream in(message); QString name; @@ -396,11 +397,17 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) int version; in >> version >> d->clientPlugins; + //Get the supported QDataStream version + if (!in.atEnd()) { + in >> s_dataStreamVersion; + if (s_dataStreamVersion > QDataStream().version()) + s_dataStreamVersion = QDataStream().version(); + } // Send the hello answer immediately, since it needs to arrive before // the plugins below start sending messages. QByteArray helloAnswer; { - QDataStream out(&helloAnswer, QIODevice::WriteOnly); + QQmlDebugStream out(&helloAnswer, QIODevice::WriteOnly); QStringList pluginNames; QList pluginVersions; foreach (QQmlDebugService *service, d->plugins.values()) { @@ -408,7 +415,8 @@ void QQmlDebugServer::receiveMessage(const QByteArray &message) pluginVersions << service->version(); } - out << QString(QStringLiteral("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions; + out << QString(QStringLiteral("QDeclarativeDebugClient")) << 0 << protocolVersion + << pluginNames << pluginVersions << s_dataStreamVersion; } d->connection->send(QList() << helloAnswer); @@ -577,7 +585,7 @@ void QQmlDebugServer::sendMessages(QQmlDebugService *service, QList prefixedMessages; foreach (const QByteArray &message, messages) { QByteArray prefixed; - QDataStream out(&prefixed, QIODevice::WriteOnly); + QQmlDebugStream out(&prefixed, QIODevice::WriteOnly); out << service->name() << message; prefixedMessages << prefixed; } diff --git a/src/qml/debugger/qqmldebugserver_p.h b/src/qml/debugger/qqmldebugserver_p.h index 5e853da..be02602 100644 --- a/src/qml/debugger/qqmldebugserver_p.h +++ b/src/qml/debugger/qqmldebugserver_p.h @@ -97,6 +97,9 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_changeServiceState(const QString &serviceName, QQmlDebugService::State state)) Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList)) + +public: + static int s_dataStreamVersion; }; QT_END_NAMESPACE diff --git a/src/qml/debugger/qqmldebugservice.cpp b/src/qml/debugger/qqmldebugservice.cpp index 1fe5aa3..76847e5 100644 --- a/src/qml/debugger/qqmldebugservice.cpp +++ b/src/qml/debugger/qqmldebugservice.cpp @@ -261,4 +261,28 @@ void QQmlDebugService::messageReceived(const QByteArray &) { } +QQmlDebugStream::QQmlDebugStream() + : QDataStream() +{ + setVersion(QQmlDebugServer::s_dataStreamVersion); +} + +QQmlDebugStream::QQmlDebugStream(QIODevice *d) + : QDataStream(d) +{ + setVersion(QQmlDebugServer::s_dataStreamVersion); +} + +QQmlDebugStream::QQmlDebugStream(QByteArray *ba, QIODevice::OpenMode flags) + : QDataStream(ba, flags) +{ + setVersion(QQmlDebugServer::s_dataStreamVersion); +} + +QQmlDebugStream::QQmlDebugStream(const QByteArray &ba) + : QDataStream(ba) +{ + setVersion(QQmlDebugServer::s_dataStreamVersion); +} + QT_END_NAMESPACE diff --git a/src/qml/debugger/qqmldebugservice_p.h b/src/qml/debugger/qqmldebugservice_p.h index abd9c1b..f092b6c 100644 --- a/src/qml/debugger/qqmldebugservice_p.h +++ b/src/qml/debugger/qqmldebugservice_p.h @@ -43,6 +43,7 @@ #define QQMLDEBUGSERVICE_H #include +#include #include @@ -105,6 +106,15 @@ private: friend class QQmlDebugServerPrivate; }; +class Q_QML_PRIVATE_EXPORT QQmlDebugStream : public QDataStream +{ +public: + QQmlDebugStream(); + explicit QQmlDebugStream(QIODevice *d); + QQmlDebugStream(QByteArray *ba, QIODevice::OpenMode flags); + QQmlDebugStream(const QByteArray &ba); +}; + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp index 588cbe2..f837da5 100644 --- a/src/qml/debugger/qqmlenginedebugservice.cpp +++ b/src/qml/debugger/qqmlenginedebugservice.cpp @@ -401,15 +401,16 @@ void QQmlEngineDebugService::messageReceived(const QByteArray &message) void QQmlEngineDebugService::processMessage(const QByteArray &message) { - QDataStream ds(message); + QQmlDebugStream ds(message); QByteArray type; int queryId; ds >> type >> queryId; + QByteArray reply; + QQmlDebugStream rs(&reply, QIODevice::WriteOnly); + if (type == "LIST_ENGINES") { - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("LIST_ENGINES_R"); rs << queryId << m_engines.count(); @@ -422,7 +423,6 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) rs << engineName << engineId; } - sendMessage(reply); } else if (type == "LIST_OBJECTS") { int engineId = -1; ds >> engineId; @@ -430,8 +430,6 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) QQmlEngine *engine = qobject_cast(QQmlDebugService::objectForId(engineId)); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("LIST_OBJECTS_R") << queryId; if (engine) { @@ -448,7 +446,6 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) buildStatesList(true, ctxtPriv->instances); } - sendMessage(reply); } else if (type == "FETCH_OBJECT") { int objectId; bool recurse; @@ -458,8 +455,6 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) QObject *object = QQmlDebugService::objectForId(objectId); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("FETCH_OBJECT_R") << queryId; if (object) { @@ -468,18 +463,14 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) buildObjectDump(rs, object, recurse, dumpProperties); } - sendMessage(reply); } else if (type == "WATCH_OBJECT") { int objectId; ds >> objectId; bool ok = m_watch->addWatch(queryId, objectId); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; - sendMessage(reply); } else if (type == "WATCH_PROPERTY") { int objectId; QByteArray property; @@ -487,11 +478,8 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) ds >> objectId >> property; bool ok = m_watch->addWatch(queryId, objectId, property); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; - sendMessage(reply); } else if (type == "WATCH_EXPR_OBJECT") { int debugId; QString expr; @@ -499,17 +487,13 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) ds >> debugId >> expr; bool ok = m_watch->addWatch(queryId, debugId, expr); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; - sendMessage(reply); + } else if (type == "NO_WATCH") { bool ok = m_watch->removeWatch(queryId); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("NO_WATCH_R") << queryId << ok; - sendMessage(reply); + } else if (type == "EVAL_EXPRESSION") { int objectId; QString expr; @@ -531,11 +515,8 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) result = QString(QStringLiteral("")); } - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; - sendMessage(reply); } else if (type == "SET_BINDING") { int objectId; QString propertyName; @@ -548,22 +529,16 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) bool ok = setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("SET_BINDING_R") << queryId << ok; - sendMessage(reply); } else if (type == "RESET_BINDING") { int objectId; QString propertyName; ds >> objectId >> propertyName; bool ok = resetBinding(objectId, propertyName); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("RESET_BINDING_R") << queryId << ok; - sendMessage(reply); } else if (type == "SET_METHOD_BODY") { int objectId; QString methodName; @@ -571,12 +546,10 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message) ds >> objectId >> methodName >> methodBody; bool ok = setMethodBody(objectId, methodName, methodBody); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("SET_METHOD_BODY_R") << queryId << ok; - sendMessage(reply); } + sendMessage(reply); } bool QQmlEngineDebugService::setBinding(int objectId, @@ -720,7 +693,7 @@ bool QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, void QQmlEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value) { QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); + QQmlDebugStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value); @@ -753,7 +726,7 @@ void QQmlEngineDebugService::objectCreated(QQmlEngine *engine, QObject *object) int parentId = QQmlDebugService::idForObject(object->parent()); QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); + QQmlDebugStream rs(&reply, QIODevice::WriteOnly); //unique queryId -1 rs << QByteArray("OBJECT_CREATED") << -1 << engineId << objectId << parentId; diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp index 12db9e1..3600586 100644 --- a/src/qml/debugger/qqmlprofilerservice.cpp +++ b/src/qml/debugger/qqmlprofilerservice.cpp @@ -64,7 +64,7 @@ QByteArray QQmlProfilerData::toByteArray() const { QByteArray data; //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << time << messageType << detailType; if (messageType == (int)QQmlProfilerService::RangeData) ds << detailData; @@ -276,7 +276,7 @@ void QQmlProfilerService::sendMessages() //indicate completion QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << (qint64)-1 << (int)Complete; messages << data; @@ -308,7 +308,7 @@ void QQmlProfilerService::messageReceived(const QByteArray &message) QMutexLocker lock(&m_initializeMutex); QByteArray rwData = message; - QDataStream stream(&rwData, QIODevice::ReadOnly); + QQmlDebugStream stream(&rwData, QIODevice::ReadOnly); bool enabled; stream >> enabled; diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp index 3ef1f32..37b06ca 100644 --- a/src/qml/debugger/qv8debugservice.cpp +++ b/src/qml/debugger/qv8debugservice.cpp @@ -223,7 +223,7 @@ void QV8DebugService::messageReceived(const QByteArray &message) Q_D(QV8DebugService); QMutexLocker lock(&d->initializeMutex); - QDataStream ds(message); + QQmlDebugStream ds(message); QByteArray header; ds >> header; @@ -250,7 +250,7 @@ void QV8DebugService::messageReceived(const QByteArray &message) sendDebugMessage(QString::fromUtf8(data)); } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) { - QDataStream rs(data); + QQmlDebugStream rs(data); QByteArray signal; bool enabled; rs >> signal >> enabled; @@ -281,7 +281,7 @@ void QV8DebugService::processDebugMessages() QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message) { QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); + QQmlDebugStream rs(&reply, QIODevice::WriteOnly); QByteArray cmd("V8DEBUG"); rs << cmd << type.toUtf8() << message.toUtf8(); return reply; diff --git a/src/qml/debugger/qv8profilerservice.cpp b/src/qml/debugger/qv8profilerservice.cpp index 5cddea7..e75156f 100644 --- a/src/qml/debugger/qv8profilerservice.cpp +++ b/src/qml/debugger/qv8profilerservice.cpp @@ -61,7 +61,7 @@ public: WriteResult WriteAsciiChunk(char *rawData, int size) { QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << QV8ProfilerService::V8SnapshotChunk << QByteArray(rawData, size); messages.append(data); return kContinue; @@ -74,7 +74,7 @@ QByteArray QV8ProfilerData::toByteArray() const { QByteArray data; //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << messageType << filename << functionname << lineNumber << totalTime << selfTime << treeLevel; return data; @@ -156,7 +156,7 @@ void QV8ProfilerService::messageReceived(const QByteArray &message) { Q_D(QV8ProfilerService); - QDataStream ds(message); + QQmlDebugStream ds(message); QByteArray command; QByteArray option; QByteArray title; @@ -206,7 +206,7 @@ void QV8ProfilerService::startProfiling(const QString &title) // indicate profiling started QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << (int)QV8ProfilerService::V8Started; sendMessage(data); @@ -231,7 +231,7 @@ void QV8ProfilerService::stopProfiling(const QString &title) } else { // indicate completion, even without data QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << (int)QV8ProfilerService::V8Complete; sendMessage(data); @@ -290,7 +290,7 @@ void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType //indicate completion QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << (int)QV8ProfilerService::V8SnapshotComplete; messages.append(data); @@ -308,7 +308,7 @@ void QV8ProfilerServicePrivate::sendMessages() //indicate completion QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); + QQmlDebugStream ds(&data, QIODevice::WriteOnly); ds << (int)QV8ProfilerService::V8Complete; messages.append(data); diff --git a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp index 12acb9f..2a561b1 100644 --- a/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp +++ b/tests/auto/qml/debugger/qqmldebugservice/tst_qqmldebugservice.cpp @@ -52,8 +52,8 @@ #include "qqmldebugclient.h" #include "qqmldebugtestservice.h" -#define PORT 13769 -#define STR_PORT "13769" +#define PORT 3769 +#define STR_PORT "3769" class tst_QQmlDebugService : public QObject { @@ -61,9 +61,10 @@ class tst_QQmlDebugService : public QObject private: QQmlDebugConnection *m_conn; + private slots: - void initTestCase(); + void initTestCase(); void name(); void version(); void state(); @@ -71,6 +72,8 @@ private slots: void idForObject(); void objectForId(); void objectToString(); + void checkSupportForDataStreamVersion(); + void checkSupportForOldDataStreamVersion(); }; void tst_QQmlDebugService::initTestCase() @@ -147,6 +150,22 @@ void tst_QQmlDebugService::sendMessage() duplicate.sendMessage("msg"); } +void tst_QQmlDebugService::checkSupportForDataStreamVersion() +{ + QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()"); + QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn); + + QByteArray msg = "hello!"; + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + + client.sendMessage(msg); + QByteArray resp = client.waitForResponse(); + QCOMPARE(resp, msg); + QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_5_0)); +} + void tst_QQmlDebugService::idForObject() { QCOMPARE(QQmlDebugService::idForObject(0), -1); @@ -194,6 +213,36 @@ void tst_QQmlDebugService::objectToString() delete obj; } +void tst_QQmlDebugService::checkSupportForOldDataStreamVersion() +{ + //create a new connection; + delete m_conn; + m_conn = new QQmlDebugConnection(this); + m_conn->setDataStreamVersion(QDataStream::Qt_4_7); + for (int i = 0; i < 50; ++i) { + // try for 5 seconds ... + m_conn->connectToHost("127.0.0.1", PORT); + if (m_conn->waitForConnected()) + break; + QTest::qSleep(100); + } + QVERIFY(m_conn->isConnected()); + + QTRY_VERIFY(QQmlDebugService::hasDebuggingClient()); + QQmlDebugTestService service("tst_QQmlDebugService::sendMessage2()"); + QQmlDebugTestClient client("tst_QQmlDebugService::sendMessage2()", m_conn); + + QByteArray msg = "hello!"; + + QTRY_COMPARE(client.state(), QQmlDebugClient::Enabled); + QTRY_COMPARE(service.state(), QQmlDebugService::Enabled); + + client.sendMessage(msg); + QByteArray resp = client.waitForResponse(); + QCOMPARE(resp, msg); + QCOMPARE(m_conn->dataStreamVersion(), int(QDataStream::Qt_4_7)); +} + int main(int argc, char *argv[]) { diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp index f0fa499..e36d596 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.cpp +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.cpp @@ -112,7 +112,8 @@ void QQmlDebugConnectionPrivate::advertisePlugins() void QQmlDebugConnectionPrivate::connected() { QPacket pack; - pack << serverId << 0 << protocolVersion << plugins.keys(); + pack << serverId << 0 << protocolVersion << plugins.keys() + << q->m_dataStreamVersion; protocol->send(pack); q->flush(); } @@ -148,6 +149,7 @@ void QQmlDebugConnectionPrivate::readyRead() serverPlugins.insert(pluginNames.at(i), pluginVersion); } + pack >> q->m_dataStreamVersion; validHello = true; } } @@ -247,7 +249,8 @@ void QQmlDebugConnectionPrivate::handshakeTimeout() } QQmlDebugConnection::QQmlDebugConnection(QObject *parent) - : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this)) + : QIODevice(parent), d(new QQmlDebugConnectionPrivate(this)), + m_dataStreamVersion(QDataStream::Qt_5_0) { } @@ -260,6 +263,16 @@ QQmlDebugConnection::~QQmlDebugConnection() } } +void QQmlDebugConnection::setDataStreamVersion(int dataStreamVersion) +{ + m_dataStreamVersion = dataStreamVersion; +} + +int QQmlDebugConnection::dataStreamVersion() +{ + return m_dataStreamVersion; +} + bool QQmlDebugConnection::isConnected() const { return state() == QAbstractSocket::ConnectedState; diff --git a/tests/auto/qml/debugger/shared/qqmldebugclient.h b/tests/auto/qml/debugger/shared/qqmldebugclient.h index 0f140a1..5275d41 100644 --- a/tests/auto/qml/debugger/shared/qqmldebugclient.h +++ b/tests/auto/qml/debugger/shared/qqmldebugclient.h @@ -55,6 +55,9 @@ public: void connectToHost(const QString &hostName, quint16 port); + void setDataStreamVersion(int dataStreamVersion); + int dataStreamVersion(); + qint64 bytesAvailable() const; bool isConnected() const; QAbstractSocket::SocketState state() const; @@ -74,8 +77,10 @@ protected: private: QQmlDebugConnectionPrivate *d; + int m_dataStreamVersion; friend class QQmlDebugClient; friend class QQmlDebugClientPrivate; + friend class QQmlDebugConnectionPrivate; }; class QQmlDebugClientPrivate;