forked from qt-creator/qt-creator
QmlDebugger: Exchange supported QDataStream versions
Use the lowest QDataStream version common to both the server and client. The server part was added to Qt 5.0 (commit 7f7cd79e), but we haven't used that yet. THis fixes a regression in the inspector where only some properties are shown. Task-number: QTCREATORBUG-10186 Change-Id: If6699eb7261e480587f6a21d54fb6b6107669b8f Reviewed-by: Robert Loehning <robert.loehning@digia.com> Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
@@ -181,7 +181,7 @@ void BaseEngineDebugClient::statusChanged(ClientStatus status)
|
||||
|
||||
void BaseEngineDebugClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QDataStream ds(data);
|
||||
QmlDebugStream ds(data);
|
||||
int queryId;
|
||||
QByteArray type;
|
||||
ds >> type >> queryId;
|
||||
@@ -254,7 +254,7 @@ quint32 BaseEngineDebugClient::addWatch(const PropertyReference &property)
|
||||
if (status() == Enabled) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("WATCH_PROPERTY") << id << property.m_objectDebugId
|
||||
<< property.m_name.toUtf8();
|
||||
sendMessage(message);
|
||||
@@ -276,7 +276,7 @@ quint32 BaseEngineDebugClient::addWatch(const ObjectReference &object,
|
||||
if (status() == Enabled) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.m_debugId << expr;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -289,7 +289,7 @@ quint32 BaseEngineDebugClient::addWatch(int objectDebugId)
|
||||
if (status() == Enabled) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("WATCH_OBJECT") << id << objectDebugId;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -306,7 +306,7 @@ void BaseEngineDebugClient::removeWatch(quint32 id)
|
||||
{
|
||||
if (status() == Enabled) {
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("NO_WATCH") << id;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -318,7 +318,7 @@ quint32 BaseEngineDebugClient::queryAvailableEngines()
|
||||
if (status() == Enabled) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("LIST_ENGINES") << id;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ quint32 BaseEngineDebugClient::queryRootContexts(const EngineReference &engine)
|
||||
if (status() == Enabled && engine.m_debugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("LIST_OBJECTS") << id << engine.m_debugId;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ quint32 BaseEngineDebugClient::queryObject(int objectId)
|
||||
if (status() == Enabled && objectId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("FETCH_OBJECT") << id << objectId << false <<
|
||||
true;
|
||||
sendMessage(message);
|
||||
@@ -358,7 +358,7 @@ quint32 BaseEngineDebugClient::queryObjectRecursive(int objectId)
|
||||
if (status() == Enabled && objectId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("FETCH_OBJECT") << id << objectId << true <<
|
||||
true;
|
||||
sendMessage(message);
|
||||
@@ -374,7 +374,7 @@ quint32 BaseEngineDebugClient::queryExpressionResult(int objectDebugId,
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr
|
||||
<< engineId;
|
||||
sendMessage(message);
|
||||
@@ -393,7 +393,7 @@ quint32 BaseEngineDebugClient::setBindingForObject(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("SET_BINDING") << id << objectDebugId << propertyName
|
||||
<< bindingExpression << isLiteralValue << source << line;
|
||||
sendMessage(message);
|
||||
@@ -409,7 +409,7 @@ quint32 BaseEngineDebugClient::resetBindingForObject(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("RESET_BINDING") << id << objectDebugId << propertyName;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ quint32 BaseEngineDebugClient::setMethodBody(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("SET_METHOD_BODY") << id << objectDebugId
|
||||
<< methodName << methodBody;
|
||||
sendMessage(message);
|
||||
@@ -439,7 +439,7 @@ quint32 BaseEngineDebugClient::queryObjectsForLocation(
|
||||
if (status() == Enabled) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("FETCH_OBJECTS_FOR_LOCATION") << id <<
|
||||
fileName << lineNumber << columnNumber << false <<
|
||||
true;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "declarativeenginedebugclient.h"
|
||||
#include "qmldebugconstants.h"
|
||||
#include "qmldebugclient.h"
|
||||
|
||||
namespace QmlDebug {
|
||||
|
||||
@@ -49,7 +50,7 @@ quint32 DeclarativeEngineDebugClient::setBindingForObject(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("SET_BINDING") << objectDebugId << propertyName
|
||||
<< bindingExpression << isLiteralValue << source << line;
|
||||
sendMessage(message);
|
||||
@@ -65,7 +66,7 @@ quint32 DeclarativeEngineDebugClient::resetBindingForObject(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
|
||||
sendMessage(message);
|
||||
}
|
||||
@@ -80,7 +81,7 @@ quint32 DeclarativeEngineDebugClient::setMethodBody(
|
||||
if (status() == Enabled && objectDebugId != -1) {
|
||||
id = getId();
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
QmlDebugStream ds(&message, QIODevice::WriteOnly);
|
||||
ds << QByteArray("SET_METHOD_BODY") << objectDebugId
|
||||
<< methodName << methodBody;
|
||||
sendMessage(message);
|
||||
@@ -90,7 +91,7 @@ quint32 DeclarativeEngineDebugClient::setMethodBody(
|
||||
|
||||
void DeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QDataStream ds(data);
|
||||
QmlDebugStream ds(data);
|
||||
QByteArray type;
|
||||
ds >> type;
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
namespace QmlDebug {
|
||||
|
||||
const int protocolVersion = 1;
|
||||
int QmlDebugClient::s_dataStreamVersion = QDataStream::Qt_4_7;
|
||||
|
||||
const QString serverId = QLatin1String("QDeclarativeDebugServer");
|
||||
const QString clientId = QLatin1String("QDeclarativeDebugClient");
|
||||
|
||||
@@ -95,7 +97,8 @@ void QmlDebugConnectionPrivate::advertisePlugins()
|
||||
void QmlDebugConnectionPrivate::connected()
|
||||
{
|
||||
QPacket pack;
|
||||
pack << serverId << 0 << protocolVersion << plugins.keys();
|
||||
QDataStream str;
|
||||
pack << serverId << 0 << protocolVersion << plugins.keys() << QDataStream().version();
|
||||
protocol->send(pack);
|
||||
q->flush();
|
||||
}
|
||||
@@ -131,6 +134,12 @@ void QmlDebugConnectionPrivate::readyRead()
|
||||
serverPlugins.insert(pluginNames.at(i), pluginVersion);
|
||||
}
|
||||
|
||||
if (!pack.isEmpty()) {
|
||||
pack >> QmlDebugClient::s_dataStreamVersion;
|
||||
if (QmlDebugClient::s_dataStreamVersion
|
||||
> QDataStream().version())
|
||||
qWarning() << "Server returned invalid data stream version!";
|
||||
}
|
||||
validHello = true;
|
||||
}
|
||||
}
|
||||
@@ -409,6 +418,30 @@ void QmlDebugClient::messageReceived(const QByteArray &)
|
||||
{
|
||||
}
|
||||
|
||||
QmlDebugStream::QmlDebugStream()
|
||||
: QDataStream()
|
||||
{
|
||||
setVersion(QmlDebugClient::s_dataStreamVersion);
|
||||
}
|
||||
|
||||
QmlDebugStream::QmlDebugStream(QIODevice *d)
|
||||
: QDataStream(d)
|
||||
{
|
||||
setVersion(QmlDebugClient::s_dataStreamVersion);
|
||||
}
|
||||
|
||||
QmlDebugStream::QmlDebugStream(QByteArray *ba, QIODevice::OpenMode flags)
|
||||
: QDataStream(ba, flags)
|
||||
{
|
||||
setVersion(QmlDebugClient::s_dataStreamVersion);
|
||||
}
|
||||
|
||||
QmlDebugStream::QmlDebugStream(const QByteArray &ba)
|
||||
: QDataStream(ba)
|
||||
{
|
||||
setVersion(QmlDebugClient::s_dataStreamVersion);
|
||||
}
|
||||
|
||||
} // namespace QmlDebug
|
||||
|
||||
#include <qmldebugclient.moc>
|
||||
|
||||
@@ -103,6 +103,18 @@ private:
|
||||
friend class QmlDebugConnection;
|
||||
friend class QmlDebugConnectionPrivate;
|
||||
QScopedPointer<QmlDebugClientPrivate> d_ptr;
|
||||
|
||||
public:
|
||||
static int s_dataStreamVersion;
|
||||
};
|
||||
|
||||
class QMLDEBUG_EXPORT QmlDebugStream : public QDataStream
|
||||
{
|
||||
public:
|
||||
QmlDebugStream();
|
||||
explicit QmlDebugStream(QIODevice *d);
|
||||
QmlDebugStream(QByteArray *ba, QIODevice::OpenMode flags);
|
||||
QmlDebugStream(const QByteArray &ba);
|
||||
};
|
||||
|
||||
} // namespace QmlDebug
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#endif
|
||||
|
||||
using namespace Core;
|
||||
using QmlDebug::QmlDebugStream;
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
@@ -522,7 +523,7 @@ void QmlV8DebuggerClientPrivate::setBreakpoint(const QString type, const QString
|
||||
// }
|
||||
if (type == _(EVENT)) {
|
||||
QByteArray params;
|
||||
QDataStream rs(¶ms, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(¶ms, QIODevice::WriteOnly);
|
||||
rs << target.toUtf8() << enabled;
|
||||
logSendMessage(QString(_("%1 %2 %3 %4")).arg(_(V8DEBUG), _(BREAKONSIGNAL), target, enabled?_("enabled"):_("disabled")));
|
||||
q->sendMessage(packMessage(BREAKONSIGNAL, params));
|
||||
@@ -892,7 +893,7 @@ QByteArray QmlV8DebuggerClientPrivate::packMessage(const QByteArray &type, const
|
||||
{
|
||||
SDEBUG(message);
|
||||
QByteArray request;
|
||||
QDataStream rs(&request, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&request, QIODevice::WriteOnly);
|
||||
QByteArray cmd = V8DEBUG;
|
||||
rs << cmd << type << message;
|
||||
return request;
|
||||
@@ -1160,7 +1161,7 @@ void QmlV8DebuggerClient::getSourceFiles()
|
||||
|
||||
void QmlV8DebuggerClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QDataStream ds(data);
|
||||
QmlDebugStream ds(data);
|
||||
QByteArray command;
|
||||
ds >> command;
|
||||
|
||||
|
||||
@@ -34,11 +34,14 @@
|
||||
#include <debugger/stackhandler.h>
|
||||
#include <debugger/debuggercore.h>
|
||||
#include <debugger/debuggerstringutils.h>
|
||||
#include <qmldebug/qmldebugclient.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using QmlDebug::QmlDebugStream;
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
|
||||
@@ -138,7 +141,7 @@ QScriptDebuggerClient::~QScriptDebuggerClient()
|
||||
void QScriptDebuggerClient::executeStep()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "STEPINTO";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -148,7 +151,7 @@ void QScriptDebuggerClient::executeStep()
|
||||
void QScriptDebuggerClient::executeStepOut()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "STEPOUT";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -158,7 +161,7 @@ void QScriptDebuggerClient::executeStepOut()
|
||||
void QScriptDebuggerClient::executeNext()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "STEPOVER";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -168,7 +171,7 @@ void QScriptDebuggerClient::executeNext()
|
||||
void QScriptDebuggerClient::executeStepI()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "STEPINTO";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -189,7 +192,7 @@ void QScriptDebuggerClient::executeRunToLine(const ContextData &data)
|
||||
void QScriptDebuggerClient::continueInferior()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "CONTINUE";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -199,7 +202,7 @@ void QScriptDebuggerClient::continueInferior()
|
||||
void QScriptDebuggerClient::interruptInferior()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "INTERRUPT";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QLatin1String(cmd));
|
||||
@@ -234,7 +237,7 @@ void QScriptDebuggerClient::resetSession()
|
||||
void QScriptDebuggerClient::activateFrame(int index)
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "ACTIVATE_FRAME";
|
||||
rs << cmd
|
||||
<< index;
|
||||
@@ -287,7 +290,7 @@ void QScriptDebuggerClient::changeBreakpoint(const BreakpointModelId &id)
|
||||
void QScriptDebuggerClient::synchronizeBreakpoints()
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "BREAKPOINTS";
|
||||
rs << cmd
|
||||
<< d->breakpoints;
|
||||
@@ -314,7 +317,7 @@ void QScriptDebuggerClient::assignValueInDebugger(const WatchData *data,
|
||||
const QVariant &valueV)
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "EXEC";
|
||||
rs << cmd;
|
||||
QString expression = QString(_("%1 = %2;")).arg(expr).arg(valueV.toString());
|
||||
@@ -328,7 +331,7 @@ void QScriptDebuggerClient::assignValueInDebugger(const WatchData *data,
|
||||
void QScriptDebuggerClient::updateWatchData(const WatchData &data)
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "EXEC";
|
||||
rs << cmd;
|
||||
rs << data.iname << data.name;
|
||||
@@ -340,7 +343,7 @@ void QScriptDebuggerClient::updateWatchData(const WatchData &data)
|
||||
void QScriptDebuggerClient::executeDebuggerCommand(const QString &command)
|
||||
{
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "EXEC";
|
||||
QByteArray console = "console";
|
||||
rs << cmd << console << command;
|
||||
@@ -353,7 +356,7 @@ void QScriptDebuggerClient::synchronizeWatchers(const QStringList &watchers)
|
||||
{
|
||||
// send watchers list
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "WATCH_EXPRESSIONS";
|
||||
rs << cmd;
|
||||
d->logSendMessage(QString::fromLatin1("%1 (%2)").arg(QLatin1String(cmd),
|
||||
@@ -368,7 +371,7 @@ void QScriptDebuggerClient::expandObject(const QByteArray &iname, quint64 object
|
||||
return;
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "EXPAND";
|
||||
rs << cmd;
|
||||
rs << iname << objectId;
|
||||
@@ -381,7 +384,7 @@ void QScriptDebuggerClient::sendPing()
|
||||
{
|
||||
d->ping++;
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
QmlDebugStream rs(&reply, QIODevice::WriteOnly);
|
||||
QByteArray cmd = "PING";
|
||||
rs << cmd;
|
||||
rs << d->ping;
|
||||
@@ -392,7 +395,7 @@ void QScriptDebuggerClient::sendPing()
|
||||
void QScriptDebuggerClient::messageReceived(const QByteArray &data)
|
||||
{
|
||||
QByteArray rwData = data;
|
||||
QDataStream stream(&rwData, QIODevice::ReadOnly);
|
||||
QmlDebugStream stream(&rwData, QIODevice::ReadOnly);
|
||||
|
||||
QByteArray command;
|
||||
stream >> command;
|
||||
|
||||
Reference in New Issue
Block a user