diff --git a/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp b/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp index 7dad4ac6833..17a00353529 100644 --- a/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp +++ b/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp @@ -33,120 +33,7 @@ namespace QmlJsDebugClient { -class QmlEngineDebugClientPrivate -{ -public: - QmlEngineDebugClientPrivate(QmlEngineDebugClient *); - ~QmlEngineDebugClientPrivate(); - - void statusChanged(QDeclarativeDebugClient::Status status); - void message(const QByteArray &); - - QmlEngineDebugClient *q; - int nextId; - int getId(); - - void decode(QDataStream &, QDeclarativeDebugContextReference &); - void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); - - static void remove(QmlEngineDebugClient *, QDeclarativeDebugEnginesQuery *); - static void remove(QmlEngineDebugClient *, QDeclarativeDebugRootContextQuery *); - static void remove(QmlEngineDebugClient *, QDeclarativeDebugObjectQuery *); - static void remove(QmlEngineDebugClient *, QDeclarativeDebugExpressionQuery *); - static void remove(QmlEngineDebugClient *, QDeclarativeDebugWatch *); - - QHash enginesQuery; - QHash rootContextQuery; - QHash objectQuery; - QHash expressionQuery; - - QHash watched; -}; - -void QmlEngineDebugClient::statusChanged(Status status) -{ - emit newStatus(status); -} - -void QmlEngineDebugClient::messageReceived(const QByteArray &data) -{ - d->message(data); -} - -QmlEngineDebugClientPrivate::QmlEngineDebugClientPrivate(QmlEngineDebugClient *q) - : q(q), nextId(0) -{ -} - -QmlEngineDebugClientPrivate::~QmlEngineDebugClientPrivate() -{ - QHash::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) - enginesIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) - rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) - objectIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) - exprIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QDeclarativeDebugWatch::Dead); - } -} - -int QmlEngineDebugClientPrivate::getId() -{ - return nextId++; -} - -void QmlEngineDebugClientPrivate::remove(QmlEngineDebugClient *c, QDeclarativeDebugEnginesQuery *q) -{ - if (c && q) { - QmlEngineDebugClientPrivate *p = c->priv(); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QmlEngineDebugClientPrivate::remove(QmlEngineDebugClient *c, - QDeclarativeDebugRootContextQuery *q) -{ - if (c && q) { - QmlEngineDebugClientPrivate *p = c->priv(); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QmlEngineDebugClientPrivate::remove(QmlEngineDebugClient *c, QDeclarativeDebugWatch *w) -{ - if (c && w) { - QmlEngineDebugClientPrivate *p = c->priv(); - p->watched.remove(w->m_queryId); - } -} - -// from qdeclarativeenginedebug_p.h -struct QDeclarativeObjectData { +struct QmlObjectData { QUrl url; int lineNumber; int columnNumber; @@ -157,14 +44,14 @@ struct QDeclarativeObjectData { int contextId; }; -QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectData &data) +QDataStream &operator>>(QDataStream &ds, QmlObjectData &data) { ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString >> data.objectName >> data.objectType >> data.objectId >> data.contextId; return ds; } -struct QDeclarativeObjectProperty { +struct QmlObjectProperty { enum Type { Unknown, Basic, Object, List, SignalProperty }; Type type; QString name; @@ -174,38 +61,23 @@ struct QDeclarativeObjectProperty { bool hasNotifySignal; }; -QDataStream &operator>>(QDataStream &ds, QDeclarativeObjectProperty &data) +QDataStream &operator>>(QDataStream &ds, QmlObjectProperty &data) { int type; ds >> type >> data.name >> data.value >> data.valueTypeName >> data.binding >> data.hasNotifySignal; - data.type = (QDeclarativeObjectProperty::Type)type; + data.type = (QmlObjectProperty::Type)type; return ds; } -void QmlEngineDebugClientPrivate::remove(QmlEngineDebugClient *c, QDeclarativeDebugObjectQuery *q) +void QmlEngineDebugClient::decode(QDataStream &ds, + QmlDebugObjectReference &o, + bool simple) { - if (c && q) { - QmlEngineDebugClientPrivate *p = c->priv(); - p->objectQuery.remove(q->m_queryId); - } -} - -void QmlEngineDebugClientPrivate::remove(QmlEngineDebugClient *c, QDeclarativeDebugExpressionQuery *q) -{ - if (c && q) { - QmlEngineDebugClientPrivate *p = c->priv(); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, - bool simple) -{ - QDeclarativeObjectData data; + QmlObjectData data; ds >> data; o.m_debugId = data.objectId; - o.m_class = data.objectType; + o.m_className = data.objectType; o.m_idString = data.idString; o.m_name = data.objectName; o.m_source.m_url = data.url; @@ -221,7 +93,7 @@ void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugObjec ds >> childCount >> recur; for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QDeclarativeDebugObjectReference()); + o.m_children.append(QmlDebugObjectReference()); decode(ds, o.m_children.last(), !recur); } @@ -229,37 +101,38 @@ void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugObjec ds >> propCount; for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeObjectProperty data; + QmlObjectProperty data; ds >> data; - QDeclarativeDebugPropertyReference prop; + QmlDebugPropertyReference prop; prop.m_objectDebugId = o.m_debugId; prop.m_name = data.name; prop.m_binding = data.binding; prop.m_hasNotifySignal = data.hasNotifySignal; prop.m_valueTypeName = data.valueTypeName; switch (data.type) { - case QDeclarativeObjectProperty::Basic: - case QDeclarativeObjectProperty::List: - case QDeclarativeObjectProperty::SignalProperty: + case QmlObjectProperty::Basic: + case QmlObjectProperty::List: + case QmlObjectProperty::SignalProperty: { prop.m_value = data.value; break; } - case QDeclarativeObjectProperty::Object: + case QmlObjectProperty::Object: { - QDeclarativeDebugObjectReference obj; + QmlDebugObjectReference obj; obj.m_debugId = prop.m_value.toInt(); prop.m_value = qVariantFromValue(obj); break; } - case QDeclarativeObjectProperty::Unknown: + case QmlObjectProperty::Unknown: break; } o.m_properties << prop; } } -void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) +void QmlEngineDebugClient::decode(QDataStream &ds, + QmlDebugContextReference &c) { ds >> c.m_name >> c.m_debugId; @@ -267,7 +140,7 @@ void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugConte ds >> contextCount; for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QDeclarativeDebugContextReference()); + c.m_contexts.append(QmlDebugContextReference()); decode(ds, c.m_contexts.last()); } @@ -275,764 +148,259 @@ void QmlEngineDebugClientPrivate::decode(QDataStream &ds, QDeclarativeDebugConte ds >> objectCount; for (int ii = 0; ii < objectCount; ++ii) { - QDeclarativeDebugObjectReference obj; + QmlDebugObjectReference obj; decode(ds, obj, true); - obj.m_contextDebugId = c.m_debugId; c.m_objects << obj; } } -void QmlEngineDebugClientPrivate::statusChanged(QDeclarativeDebugClient::Status status) +void QmlEngineDebugClient::statusChanged(Status status) { - emit q->statusChanged(status); + emit newStatus(status); } -void QmlEngineDebugClientPrivate::message(const QByteArray &data) +void QmlEngineDebugClient::messageReceived(const QByteArray &data) { QDataStream ds(data); - + int queryId; QByteArray type; ds >> type; - //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; + if (type == "OBJECT_CREATED") { + emit newObjects(); + return; + } + + ds >> queryId; if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - int count; ds >> count; - + QmlDebugEngineReferenceList engines; for (int ii = 0; ii < count; ++ii) { - QDeclarativeDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; + QmlDebugEngineReference eng; + ds >> eng.m_name; + ds >> eng.m_debugId; + engines << eng; } - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); + emit result(queryId, QVariant::fromValue(engines)); } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - + QmlDebugContextReference rootContext; if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); + decode(ds, rootContext); + emit result(queryId, QVariant::fromValue(rootContext)); } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - + QmlDebugObjectReference object; if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); + decode(ds, object, false); + emit result(queryId, QVariant::fromValue(object)); + } else if (type == "EVAL_EXPRESSION_R") {; + QVariant exprResult; + ds >> exprResult; + emit result(queryId, exprResult); + } else if (type == "WATCH_PROPERTY_R" || + type == "WATCH_OBJECT_R" || + type == "WATCH_EXPR_OBJECT_R") { + bool valid; + ds >> valid; + emit result(queryId, valid); } else if (type == "UPDATE_WATCH") { - int queryId; int debugId; QByteArray name; QVariant value; - ds >> queryId >> debugId >> name >> value; - - QDeclarativeDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q->newObjects(); + ds >> debugId >> name >> value; + emit valueChanged(debugId, name, value); } } -QmlEngineDebugClient::QmlEngineDebugClient(QDeclarativeDebugConnection *client) - : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), - d(new QmlEngineDebugClientPrivate(this)) +QmlEngineDebugClient::QmlEngineDebugClient( + QDeclarativeDebugConnection *connection) + : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), connection), + m_nextId(1) { } -QmlEngineDebugClient::~QmlEngineDebugClient() +quint32 QmlEngineDebugClient::addWatch(const QmlDebugPropertyReference &property) { - delete d; -} - -QDeclarativeDebugPropertyWatch *QmlEngineDebugClient::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) -{ - QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); + quint32 id; if (status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); + ds << QByteArray("WATCH_PROPERTY") << id << property.m_objectDebugId + << property.m_name.toUtf8(); sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; } - - return watch; + return id; } -QDeclarativeDebugWatch *QmlEngineDebugClient::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) +quint32 QmlEngineDebugClient::addWatch(const QmlDebugContextReference &/*context*/, + const QString &/*id*/) { - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); + qWarning("QmlEngineDebugClient::addWatch(): Not implemented"); return 0; } -QDeclarativeDebugObjectExpressionWatch *QmlEngineDebugClient::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) +quint32 QmlEngineDebugClient::addWatch(const QmlDebugObjectReference &object, + const QString &expr) { - QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - d->watched.insert(queryId, watch); - + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr; + ds << QByteArray("WATCH_EXPR_OBJECT") << id << object.m_debugId << expr; sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; } - return watch; + return id; } -QDeclarativeDebugWatch *QmlEngineDebugClient::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) +quint32 QmlEngineDebugClient::addWatch(const QmlDebugObjectReference &object) { - QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - d->watched.insert(queryId, watch); - + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId(); + ds << QByteArray("WATCH_OBJECT") << id << object.m_debugId; sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; } - - return watch; + return id; } -QDeclarativeDebugWatch *QmlEngineDebugClient::addWatch(const QDeclarativeDebugFileReference &, QObject *) +quint32 QmlEngineDebugClient::addWatch(const QmlDebugFileReference &/*file*/) { - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); + qWarning("QmlEngineDebugClient::addWatch(): Not implemented"); return 0; } -void QmlEngineDebugClient::removeWatch(QDeclarativeDebugWatch *watch) +void QmlEngineDebugClient::removeWatch(quint32 id) { - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QDeclarativeDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - if (status() == QDeclarativeDebugClient::Enabled) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); + ds << QByteArray("NO_WATCH") << id; sendMessage(message); } } -QDeclarativeDebugEnginesQuery *QmlEngineDebugClient::queryAvailableEngines(QObject *parent) +quint32 QmlEngineDebugClient::queryAvailableEngines() { - QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; + ds << QByteArray("LIST_ENGINES") << id; sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; } - - return query; + return id; } -QDeclarativeDebugRootContextQuery *QmlEngineDebugClient::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) +quint32 QmlEngineDebugClient::queryRootContexts(const QmlDebugEngineReference &engine) { - QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); - if (status() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - + quint32 id = 0; + if (status() == QDeclarativeDebugClient::Enabled && engine.m_debugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); + ds << QByteArray("LIST_OBJECTS") << id << engine.m_debugId; sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; } - - return query; + return id; } -QDeclarativeDebugObjectQuery *QmlEngineDebugClient::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) +quint32 QmlEngineDebugClient::queryObject(const QmlDebugObjectReference &object) { - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - + quint32 id = 0; + if (status() == QDeclarativeDebugClient::Enabled && object.m_debugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; + ds << QByteArray("FETCH_OBJECT") << id << object.m_debugId << false << + true; sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; } - - return query; + return id; } -QDeclarativeDebugObjectQuery *QmlEngineDebugClient::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) +quint32 QmlEngineDebugClient::queryObjectRecursive(const QmlDebugObjectReference &object) { - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (status() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - + quint32 id = 0; + if (status() == QDeclarativeDebugClient::Enabled && object.m_debugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; + ds << QByteArray("FETCH_OBJECT") << id << object.m_debugId << true << + true; sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; } - - return query; + return id; } -QDeclarativeDebugExpressionQuery *QmlEngineDebugClient::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) +quint32 QmlEngineDebugClient::queryExpressionResult(int objectDebugId, + const QString &expr) { - QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; + ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr; sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; } - - return query; + return id; } -bool QmlEngineDebugClient::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) +quint32 QmlEngineDebugClient::setBindingForObject( + int objectDebugId, + const QString &propertyName, + const QVariant &bindingExpression, + bool isLiteralValue, + QString source, int line) { + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; + ds << QByteArray("SET_BINDING") << objectDebugId << propertyName + << bindingExpression << isLiteralValue << source << line; sendMessage(message); - return true; - } else { - return false; } + return id; } -bool QmlEngineDebugClient::resetBindingForObject(int objectDebugId, const QString &propertyName) +quint32 QmlEngineDebugClient::resetBindingForObject( + int objectDebugId, + const QString &propertyName) { + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; sendMessage(message); - return true; - } else { - return false; } + return id; } -bool QmlEngineDebugClient::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) +quint32 QmlEngineDebugClient::setMethodBody( + int objectDebugId, const QString &methodName, + const QString &methodBody) { + quint32 id = 0; if (status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { + id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; + ds << QByteArray("SET_METHOD_BODY") << objectDebugId + << methodName << methodBody; sendMessage(message); - return true; - } else { - return false; } -} - -QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) - : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QDeclarativeDebugWatch::~QDeclarativeDebugWatch() -{ - if (m_client && m_queryId != -1) - QmlEngineDebugClientPrivate::remove(m_client, this); -} - -int QDeclarativeDebugWatch::queryId() const -{ - return m_queryId; -} - -int QDeclarativeDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const -{ - return m_state; -} - -void QDeclarativeDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugPropertyWatch::name() const -{ - return m_name; -} - - -QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) - : QObject(parent), m_state(Waiting) -{ -} - -QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const -{ - return m_state; -} - -bool QDeclarativeDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QDeclarativeDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QmlEngineDebugClientPrivate::remove(m_client, this); -} - -QList QDeclarativeDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QmlEngineDebugClientPrivate::remove(m_client, this); -} - -QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QmlEngineDebugClientPrivate::remove(m_client, this); -} - -QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const -{ - return m_object; -} - -QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QmlEngineDebugClientPrivate::remove(m_client, this); -} - -QVariant QDeclarativeDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QDeclarativeDebugExpressionQuery::result() const -{ - return m_result; -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) - : m_debugId(debugId) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QDeclarativeDebugEngineReference & -QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QDeclarativeDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugEngineReference::name() const -{ - return m_name; -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() - : m_debugId(-1), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) - : m_debugId(debugId), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) - : m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), - m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) -{ -} - -QDeclarativeDebugObjectReference & -QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QDeclarativeDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugObjectReference::className() const -{ - return m_class; -} - -QString QDeclarativeDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QDeclarativeDebugObjectReference::name() const -{ - return m_name; -} - -QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const -{ - return m_source; -} - -int QDeclarativeDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList QDeclarativeDebugObjectReference::properties() const -{ - return m_properties; -} - -QList QDeclarativeDebugObjectReference::children() const -{ - return m_children; -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts) -{ -} - -QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QDeclarativeDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugContextReference::name() const -{ - return m_name; -} - -QList QDeclarativeDebugContextReference::objects() const -{ - return m_objects; -} - -QList QDeclarativeDebugContextReference::contexts() const -{ - return m_contexts; -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() - : m_lineNumber(-1), m_columnNumber(-1) -{ -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o) - : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber) -{ -} - -QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QDeclarativeDebugFileReference::url() const -{ - return m_url; -} - -void QDeclarativeDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QDeclarativeDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QDeclarativeDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QDeclarativeDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QDeclarativeDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() - : m_objectDebugId(-1), m_hasNotifySignal(false) -{ -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o) - : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), - m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding), - m_hasNotifySignal(o.m_hasNotifySignal) -{ -} - -QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(const QDeclarativeDebugPropertyReference &o) -{ - m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; - m_valueTypeName = o.m_valueTypeName; m_binding = o.m_binding; - m_hasNotifySignal = o.m_hasNotifySignal; - return *this; -} - -int QDeclarativeDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QDeclarativeDebugPropertyReference::name() const -{ - return m_name; -} - -QString QDeclarativeDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QDeclarativeDebugPropertyReference::value() const -{ - return m_value; -} - -QString QDeclarativeDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QDeclarativeDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; + return id; } } // namespace QmlJsDebugClient diff --git a/src/libs/qmljsdebugclient/qmlenginedebugclient.h b/src/libs/qmljsdebugclient/qmlenginedebugclient.h index 59ee2186fc0..48917cdade0 100644 --- a/src/libs/qmljsdebugclient/qmlenginedebugclient.h +++ b/src/libs/qmljsdebugclient/qmlenginedebugclient.h @@ -40,256 +40,157 @@ namespace QmlJsDebugClient { class QDeclarativeDebugConnection; -class QDeclarativeDebugWatch; -class QDeclarativeDebugPropertyWatch; -class QDeclarativeDebugObjectExpressionWatch; -class QDeclarativeDebugEnginesQuery; -class QDeclarativeDebugRootContextQuery; -class QDeclarativeDebugObjectQuery; -class QDeclarativeDebugExpressionQuery; -class QDeclarativeDebugPropertyReference; -class QDeclarativeDebugContextReference; -class QDeclarativeDebugObjectReference; -class QDeclarativeDebugFileReference; -class QDeclarativeDebugEngineReference; -class QmlEngineDebugClientPrivate; +class QmlDebugPropertyReference; +class QmlDebugContextReference; +class QmlDebugObjectReference; +class QmlDebugFileReference; +class QmlDebugEngineReference; class QMLJSDEBUGCLIENT_EXPORT QmlEngineDebugClient : public QDeclarativeDebugClient { Q_OBJECT public: - explicit QmlEngineDebugClient(QDeclarativeDebugConnection *); - ~QmlEngineDebugClient(); + QmlEngineDebugClient(QDeclarativeDebugConnection *conn); - QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, - QObject *parent = 0); + quint32 addWatch(const QmlDebugPropertyReference &property); + quint32 addWatch(const QmlDebugContextReference &context, const QString &id); + quint32 addWatch(const QmlDebugObjectReference &object, const QString &expr); + quint32 addWatch(const QmlDebugObjectReference &object); + quint32 addWatch(const QmlDebugFileReference &file); - void removeWatch(QDeclarativeDebugWatch *watch); + void removeWatch(quint32 watch); - QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0); - QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, - const QString &expr, - QObject *parent = 0); - bool setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, bool isLiteralValue, - QString source = QString(), int line = -1); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); + quint32 queryAvailableEngines(); + quint32 queryRootContexts(const QmlDebugEngineReference &context); + quint32 queryObject(const QmlDebugObjectReference &object); + quint32 queryObjectRecursive(const QmlDebugObjectReference &object); + quint32 queryExpressionResult(int objectDebugId, + const QString &expr); + quint32 setBindingForObject(int objectDebugId, const QString &propertyName, + const QVariant &bindingExpression, + bool isLiteralValue, + QString source, int line); + quint32 resetBindingForObject(int objectDebugId, + const QString &propertyName); + quint32 setMethodBody(int objectDebugId, const QString &methodName, + const QString &methodBody); - QmlEngineDebugClientPrivate *priv() const { return d; } -Q_SIGNALS: - void newObjects(); +signals: void newStatus(QDeclarativeDebugClient::Status status); + void newObjects(); + void valueChanged(int debugId, const QByteArray &name, + const QVariant &value); + void result(quint32 queryId, const QVariant &result); protected: virtual void statusChanged(Status status); virtual void messageReceived(const QByteArray &); private: - friend class QmlEngineDebugClientPrivate; - QmlEngineDebugClientPrivate *d; + quint32 getId() { return m_nextId++; } + + void decode(QDataStream &d, QmlDebugContextReference &context); + void decode(QDataStream &d, QmlDebugObjectReference &object, bool simple); + +private: + quint32 m_nextId; }; -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugWatch : public QObject +class QmlDebugFileReference { - Q_OBJECT public: - enum State { Waiting, Active, Inactive, Dead }; + QmlDebugFileReference() : m_lineNumber(-1), m_columnNumber(-1) {} - QDeclarativeDebugWatch(QObject *); - ~QDeclarativeDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugWatch::State); - //void objectChanged(int, const QDeclarativeDebugObjectReference &); - //void valueChanged(int, const QVariant &); - - // Server sends value as string if it is a user-type variant - void valueChanged(const QByteArray &name, const QVariant &value); + QUrl url() const { return m_url; } + int lineNumber() const { return m_lineNumber; } + int columnNumber() const { return m_columnNumber; } private: friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - void setState(State); - State m_state; - int m_queryId; - QmlEngineDebugClient *m_client; - int m_objectDebugId; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QmlEngineDebugClient; - QString m_name; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QmlEngineDebugClient; - QString m_expr; - int m_debugId; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugQuery : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -Q_SIGNALS: - void stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State); - -protected: - QDeclarativeDebugQuery(QObject *); - -private: - friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - void setState(State); - State m_state; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugFileReference -{ -public: - QDeclarativeDebugFileReference(); - QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); - QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QmlEngineDebugClientPrivate; QUrl m_url; int m_lineNumber; int m_columnNumber; }; -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugEngineReference +class QmlDebugEngineReference { public: - QDeclarativeDebugEngineReference(); - QDeclarativeDebugEngineReference(int); - QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); - QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); + QmlDebugEngineReference() : m_debugId(-1) {} + QmlDebugEngineReference(int id) : m_debugId(id) {} - int debugId() const; - QString name() const; + int debugId() const { return m_debugId; } + QString name() const { return m_name; } private: - friend class QmlEngineDebugClientPrivate; + friend class QmlEngineDebugClient; int m_debugId; QString m_name; }; -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugObjectReference +typedef QList QmlDebugEngineReferenceList; + +class QmlDebugObjectReference { public: - QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectReference(int); - QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); - QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); + QmlDebugObjectReference() : m_debugId(-1), m_contextDebugId(-1) {} + QmlDebugObjectReference(int id) : m_debugId(id), m_contextDebugId(-1) {} - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; + int debugId() const { return m_debugId; } + QString className() const { return m_className; } + QString idString() const { return m_idString; } + QString name() const { return m_name; } - QDeclarativeDebugFileReference source() const; - int contextDebugId() const; + QmlDebugFileReference source() const { return m_source; } + int contextDebugId() const { return m_contextDebugId; } - QList properties() const; - QList children() const; + QList properties() const { return m_properties; } + QList children() const { return m_children; } private: - friend class QmlEngineDebugClientPrivate; + friend class QmlEngineDebugClient; int m_debugId; - QString m_class; + QString m_className; QString m_idString; QString m_name; - QDeclarativeDebugFileReference m_source; + QmlDebugFileReference m_source; int m_contextDebugId; - QList m_properties; - QList m_children; + QList m_properties; + QList m_children; }; -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugContextReference +class QmlDebugContextReference { public: - QDeclarativeDebugContextReference(); - QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); - QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); + QmlDebugContextReference() : m_debugId(-1) {} - int debugId() const; - QString name() const; + int debugId() const { return m_debugId; } + QString name() const { return m_name; } - QList objects() const; - QList contexts() const; + QList objects() const { return m_objects; } + QList contexts() const { return m_contexts; } private: - friend class QmlEngineDebugClientPrivate; + friend class QmlEngineDebugClient; int m_debugId; QString m_name; - QList m_objects; - QList m_contexts; + QList m_objects; + QList m_contexts; }; -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugPropertyReference +class QmlDebugPropertyReference { public: - QDeclarativeDebugPropertyReference(); - QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); - QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); + QmlDebugPropertyReference() : m_objectDebugId(-1), m_hasNotifySignal(false) {} - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; + int debugId() const { return m_objectDebugId; } + QString name() const { return m_name; } + QVariant value() const { return m_value; } + QString valueTypeName() const { return m_valueTypeName; } + QString binding() const { return m_binding; } + bool hasNotifySignal() const { return m_hasNotifySignal; } private: - friend class QmlEngineDebugClientPrivate; + friend class QmlEngineDebugClient; int m_objectDebugId; QString m_name; QVariant m_value; @@ -298,75 +199,11 @@ private: bool m_hasNotifySignal; }; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugEnginesQuery(); - QList engines() const; -private: - friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - QDeclarativeDebugEnginesQuery(QObject *); - QmlEngineDebugClient *m_client; - int m_queryId; - QList m_engines; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugRootContextQuery(); - QDeclarativeDebugContextReference rootContext() const; -private: - friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - QDeclarativeDebugRootContextQuery(QObject *); - QmlEngineDebugClient *m_client; - int m_queryId; - QDeclarativeDebugContextReference m_context; -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugObjectQuery(); - QDeclarativeDebugObjectReference object() const; -private: - friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - QDeclarativeDebugObjectQuery(QObject *); - QmlEngineDebugClient *m_client; - int m_queryId; - QDeclarativeDebugObjectReference m_object; - -}; - -class QMLJSDEBUGCLIENT_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QmlEngineDebugClient; - friend class QmlEngineDebugClientPrivate; - QDeclarativeDebugExpressionQuery(QObject *); - QmlEngineDebugClient *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - } // namespace QmlJsDebugClient -Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugEngineReference) -Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugObjectReference) -Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugContextReference) -Q_DECLARE_METATYPE(QmlJsDebugClient::QDeclarativeDebugPropertyReference) +Q_DECLARE_METATYPE(QmlJsDebugClient::QmlDebugObjectReference) +Q_DECLARE_METATYPE(QmlJsDebugClient::QmlDebugEngineReference) +Q_DECLARE_METATYPE(QmlJsDebugClient::QmlDebugEngineReferenceList) +Q_DECLARE_METATYPE(QmlJsDebugClient::QmlDebugContextReference) #endif // QMLENGINEDEBUGCLIENT_H diff --git a/src/plugins/debugger/qml/qmladapter.cpp b/src/plugins/debugger/qml/qmladapter.cpp index 77e7964113e..550527beb9d 100644 --- a/src/plugins/debugger/qml/qmladapter.cpp +++ b/src/plugins/debugger/qml/qmladapter.cpp @@ -311,7 +311,17 @@ QmlJsDebugClient::QmlEngineDebugClient *QmlAdapter::engineDebugClient() const void QmlAdapter::setEngineDebugClient(QmlJsDebugClient::QmlEngineDebugClient *client) { + Internal::QmlEngine *engine = + qobject_cast(d->m_engine.data()); + if (engine && d->m_engineDebugClient) + disconnect(d->m_engineDebugClient, SIGNAL(result(quint32,QVariant)), + engine, + SLOT(expressionEvaluated(quint32,QVariant))); d->m_engineDebugClient = client; + if (engine && d->m_engineDebugClient) + connect(d->m_engineDebugClient, SIGNAL(result(quint32,QVariant)), + engine, + SLOT(expressionEvaluated(quint32,QVariant))); } QmlJsDebugClient::QDebugMessageClient *QmlAdapter::messageClient() const diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index aae783138ec..92d8b1b430d 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -120,6 +121,7 @@ private: bool m_validContext; QHash pendingBreakpoints; bool m_retryOnConnectFail; + QList queryIds; }; QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q) @@ -1038,21 +1040,14 @@ void QmlEngine::synchronizeWatchers() } } -void QmlEngine::onDebugQueryStateChanged( - QmlJsDebugClient::QDeclarativeDebugQuery::State state) +void QmlEngine::expressionEvaluated(quint32 queryId, const QVariant &result) { - QmlJsDebugClient::QDeclarativeDebugExpressionQuery *query = - qobject_cast( - sender()); - if (query && state != QmlJsDebugClient::QDeclarativeDebugQuery::Error) { - QtMessageLogItem *item = constructLogItemTree(query->result()); + if (d->queryIds.contains(queryId)) { + d->queryIds.removeOne(queryId); + QtMessageLogItem *item = constructLogItemTree(result); if (item) qtMessageLogHandler()->appendItem(item); - } else - qtMessageLogHandler()-> - appendItem(new QtMessageLogItem(QtMessageLogHandler::ErrorType, - _("Error evaluating expression."))); - delete query; + } } bool QmlEngine::hasCapability(unsigned cap) const @@ -1154,16 +1149,19 @@ bool QmlEngine::evaluateScriptExpression(const QString& expression) int id = d->m_adapter.currentSelectedDebugId(); if (engineDebug && id != -1) { - QDeclarativeDebugExpressionQuery *query = - engineDebug->queryExpressionResult(id, expression); - connect(query, - SIGNAL(stateChanged( - QmlJsDebugClient::QDeclarativeDebugQuery - ::State)), - this, - SLOT(onDebugQueryStateChanged( - QmlJsDebugClient::QDeclarativeDebugQuery - ::State))); + quint32 queryId = + engineDebug->queryExpressionResult( + id, expression); + if (queryId) { + d->queryIds << queryId; + } else { + didEvaluate = false; + qtMessageLogHandler()-> + appendItem( + new QtMessageLogItem( + QtMessageLogHandler::ErrorType, + _("Error evaluating expression."))); + } } } else { executeDebuggerCommand(expression); diff --git a/src/plugins/debugger/qml/qmlengine.h b/src/plugins/debugger/qml/qmlengine.h index 5999e57c738..71a7a6b2b77 100644 --- a/src/plugins/debugger/qml/qmlengine.h +++ b/src/plugins/debugger/qml/qmlengine.h @@ -34,7 +34,6 @@ #define DEBUGGER_QMLENGINE_H #include "debuggerengine.h" -#include #include #include #include @@ -96,6 +95,7 @@ public: public slots: void disconnected(); void documentUpdated(QmlJS::Document::Ptr doc); + void expressionEvaluated(quint32 queryId, const QVariant &result); private slots: void errorMessageBoxFinished(int result); @@ -171,8 +171,6 @@ private slots: void appendMessage(const QString &msg, Utils::OutputFormat); void synchronizeWatchers(); - void onDebugQueryStateChanged( - QmlJsDebugClient::QDeclarativeDebugQuery::State state); private: void closeConnection(); diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index 4838320d259..132a03f73b7 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -53,13 +53,14 @@ ClientProxy::ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent) , m_adapter(adapter) , m_engineClient(0) , m_inspectorClient(0) - , m_engineQuery(0) - , m_contextQuery(0) + , m_engineQueryId(0) + , m_contextQueryId(0) , m_isConnected(false) { m_requestObjectsTimer.setSingleShot(true); m_requestObjectsTimer.setInterval(3000); - connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree())); + connect(&m_requestObjectsTimer, SIGNAL(timeout()), + this, SLOT(refreshObjectTree())); connectToServer(); } @@ -74,15 +75,22 @@ void ClientProxy::connectToServer() m_engineClient = new QmlEngineDebugClient(m_adapter.data()->connection()); connect(m_engineClient, SIGNAL(newObjects()), this, SLOT(newObjects())); - connect(m_engineClient, SIGNAL(statusChanged(QDeclarativeDebugClient::Status)), + connect(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)), + SLOT(clientStatusChanged(QDeclarativeDebugClient::Status))); + connect(m_engineClient, SIGNAL(newStatus(QDeclarativeDebugClient::Status)), + SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status))); + connect(m_engineClient, SIGNAL(result(quint32,QVariant)), + SLOT(onResult(quint32,QVariant))); + connect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)), + SLOT(objectWatchTriggered(int,QByteArray,QVariant))); + + + m_inspectorClient = + new QmlJSInspectorClient(m_adapter.data()->connection(), this); + + connect(m_inspectorClient, + SIGNAL(connectedStatusChanged(QDeclarativeDebugClient::Status)), this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status))); - connect(m_engineClient, SIGNAL(statusChanged(QDeclarativeDebugClient::Status)), - this, SLOT(engineClientStatusChanged(QDeclarativeDebugClient::Status))); - - m_inspectorClient = new QmlJSInspectorClient(m_adapter.data()->connection(), this); - - connect(m_inspectorClient, SIGNAL(connectedStatusChanged(QDeclarativeDebugClient::Status)), - this, SLOT(clientStatusChanged(QDeclarativeDebugClient::Status))); connect(m_inspectorClient, SIGNAL(currentObjectsChanged(QList)), SLOT(onCurrentObjectsChanged(QList))); connect(m_inspectorClient, SIGNAL(colorPickerActivated()), @@ -127,26 +135,27 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status) void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status) { if (status == QDeclarativeDebugClient::Enabled) { - m_adapter.data()->setEngineDebugClient(qobject_cast(sender())); + m_adapter.data()->setEngineDebugClient( + qobject_cast(sender())); } } void ClientProxy::refreshObjectTree() { - if (!m_contextQuery) { + if (!m_contextQueryId) { m_requestObjectsTimer.stop(); - qDeleteAll(m_objectTreeQuery); - m_objectTreeQuery.clear(); + m_objectTreeQueryIds.clear(); queryEngineContext(m_engines.value(0).debugId()); } } -void ClientProxy::onCurrentObjectsChanged(const QList &debugIds, bool requestIfNeeded) +void ClientProxy::onCurrentObjectsChanged(const QList &debugIds, + bool requestIfNeeded) { - QList selectedItems; + QList selectedItems; foreach (int debugId, debugIds) { - QDeclarativeDebugObjectReference ref = objectReferenceForId(debugId); + QmlDebugObjectReference ref = objectReferenceForId(debugId); if (ref.debugId() != -1) { selectedItems << ref; } else if (requestIfNeeded) { @@ -171,12 +180,13 @@ void ClientProxy::setSelectedItemsByDebugId(const QList &debugIds) m_inspectorClient->setCurrentObjects(debugIds); } -void ClientProxy::setSelectedItemsByObjectId(const QList &objectRefs) +void ClientProxy::setSelectedItemsByObjectId( + const QList &objectRefs) { if (isConnected()) { QList debugIds; - foreach (const QDeclarativeDebugObjectReference &ref, objectRefs) { + foreach (const QmlDebugObjectReference &ref, objectRefs) { debugIds << ref.debugId(); } @@ -184,14 +194,14 @@ void ClientProxy::setSelectedItemsByObjectId(const QListlogServiceActivity("QDeclarativeDebug", msg); } -QList QmlJSInspector::Internal::ClientProxy::rootObjectReference() const +QList +QmlJSInspector::Internal::ClientProxy::rootObjectReference() const { return m_rootObjects; } -QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId, - const QDeclarativeDebugObjectReference &objectRef) const +QmlDebugObjectReference +ClientProxy::objectReferenceForId(int debugId, + const QmlDebugObjectReference &objectRef) const { if (objectRef.debugId() == debugId) return objectRef; - foreach (const QDeclarativeDebugObjectReference &child, objectRef.children()) { - QDeclarativeDebugObjectReference result = objectReferenceForId(debugId, child); + foreach (const QmlDebugObjectReference &child, objectRef.children()) { + QmlDebugObjectReference result = objectReferenceForId(debugId, child); if (result.debugId() == debugId) return result; } - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); } -QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(const QString &objectId) const +QmlDebugObjectReference ClientProxy::objectReferenceForId( + const QString &objectId) const { if (!objectId.isEmpty() && objectId[0].isLower()) { - const QList refs = objectReferences(); - foreach (const QDeclarativeDebugObjectReference &ref, refs) { + const QList refs = objectReferences(); + foreach (const QmlDebugObjectReference &ref, refs) { if (ref.idString() == objectId) return ref; } } - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); } -QDeclarativeDebugObjectReference ClientProxy::objectReferenceForLocation(const int line, const int column) const +QmlDebugObjectReference ClientProxy::objectReferenceForLocation( + const int line, const int column) const { - const QList refs = objectReferences(); - foreach (const QDeclarativeDebugObjectReference &ref, refs) { + const QList refs = objectReferences(); + foreach (const QmlDebugObjectReference &ref, refs) { if (ref.source().lineNumber() == line && ref.source().columnNumber() == column) return ref; } - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); } -QList ClientProxy::objectReferences() const +QList ClientProxy::objectReferences() const { - QList result; - foreach (const QDeclarativeDebugObjectReference &it, m_rootObjects) { + QList result; + foreach (const QmlDebugObjectReference &it, m_rootObjects) { result.append(objectReferences(it)); } return result; } -QList ClientProxy::objectReferences(const QDeclarativeDebugObjectReference &objectRef) const +QList +ClientProxy::objectReferences(const QmlDebugObjectReference &objectRef) const { - QList result; + QList result; result.append(objectRef); - foreach (const QDeclarativeDebugObjectReference &child, objectRef.children()) { + foreach (const QmlDebugObjectReference &child, objectRef.children()) { result.append(objectReferences(child)); } return result; } -bool ClientProxy::setBindingForObject(int objectDebugId, +quint32 ClientProxy::setBindingForObject(int objectDebugId, const QString &propertyName, const QVariant &value, bool isLiteralValue, @@ -288,17 +303,23 @@ bool ClientProxy::setBindingForObject(int objectDebugId, if (!isConnected()) return false; - log(LogSend, QString("SET_BINDING %1 %2 %3 %4").arg(QString::number(objectDebugId), propertyName, value.toString(), QString(isLiteralValue ? "true" : "false"))); + log(LogSend, QString("SET_BINDING %1 %2 %3 %4").arg( + QString::number(objectDebugId), propertyName, value.toString(), + QString(isLiteralValue ? "true" : "false"))); - bool result = m_engineClient->setBindingForObject(objectDebugId, propertyName, value.toString(), isLiteralValue, source, line); + quint32 queryId = m_engineClient->setBindingForObject( + objectDebugId, propertyName, value.toString(), isLiteralValue, + source, line); - if (!result) + if (!queryId) log(LogSend, QString("failed!")); - return result; + return queryId; } -bool ClientProxy::setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody) +quint32 ClientProxy::setMethodBodyForObject(int objectDebugId, + const QString &methodName, + const QString &methodBody) { if (objectDebugId == -1) return false; @@ -306,17 +327,20 @@ bool ClientProxy::setMethodBodyForObject(int objectDebugId, const QString &metho if (!isConnected()) return false; - log(LogSend, QString("SET_METHOD_BODY %1 %2 %3").arg(QString::number(objectDebugId), methodName, methodBody)); + log(LogSend, QString("SET_METHOD_BODY %1 %2 %3").arg( + QString::number(objectDebugId), methodName, methodBody)); - bool result = m_engineClient->setMethodBody(objectDebugId, methodName, methodBody); + quint32 queryId = m_engineClient->setMethodBody( + objectDebugId, methodName, methodBody); - if (!result) + if (!queryId) log(LogSend, QString("failed!")); - return result; + return queryId; } -bool ClientProxy::resetBindingForObject(int objectDebugId, const QString& propertyName) +quint32 ClientProxy::resetBindingForObject(int objectDebugId, + const QString& propertyName) { if (objectDebugId == -1) return false; @@ -324,17 +348,20 @@ bool ClientProxy::resetBindingForObject(int objectDebugId, const QString& proper if (!isConnected()) return false; - log(LogSend, QString("RESET_BINDING %1 %2").arg(QString::number(objectDebugId), propertyName)); + log(LogSend, QString("RESET_BINDING %1 %2").arg( + QString::number(objectDebugId), propertyName)); - bool result = m_engineClient->resetBindingForObject(objectDebugId, propertyName); + quint32 queryId = m_engineClient->resetBindingForObject( + objectDebugId, propertyName); - if (!result) + if (!queryId) log(LogSend, QString("failed!")); - return result; + return queryId; } -QDeclarativeDebugExpressionQuery *ClientProxy::queryExpressionResult(int objectDebugId, const QString &expr) +quint32 ClientProxy::queryExpressionResult(int objectDebugId, + const QString &expr) { if (objectDebugId == -1) return 0; @@ -346,13 +373,13 @@ QDeclarativeDebugExpressionQuery *ClientProxy::queryExpressionResult(int objectD if (m_adapter) block = m_adapter.data()->disableJsDebugging(true); - log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg(QString::number(objectDebugId), expr)); - QDeclarativeDebugExpressionQuery *query - = m_engineClient->queryExpressionResult(objectDebugId, expr, m_engineClient); + log(LogSend, QString("EVAL_EXPRESSION %1 %2").arg( + QString::number(objectDebugId), expr)); + quint32 queryId = m_engineClient->queryExpressionResult(objectDebugId, expr); if (m_adapter) m_adapter.data()->disableJsDebugging(block); - return query; + return queryId; } void ClientProxy::clearComponentCache() @@ -370,32 +397,28 @@ bool ClientProxy::addObjectWatch(int objectDebugId) return false; // already set - if (m_objectWatches.keys().contains(objectDebugId)) + if (m_objectWatches.contains(objectDebugId)) return true; - QDeclarativeDebugObjectReference ref = objectReferenceForId(objectDebugId); + QmlDebugObjectReference ref = objectReferenceForId(objectDebugId); if (ref.debugId() != objectDebugId) return false; // is flooding the debugging output log! // log(LogSend, QString("WATCH_PROPERTY %1").arg(objectDebugId)); - QDeclarativeDebugWatch *watch = m_engineClient->addWatch(ref, m_engineClient); - m_objectWatches.insert(objectDebugId, watch); - - connect(watch,SIGNAL(valueChanged(QByteArray,QVariant)),this,SLOT(objectWatchTriggered(QByteArray,QVariant))); + if (m_engineClient->addWatch(ref)) + m_objectWatches.append(objectDebugId); return false; } -void ClientProxy::objectWatchTriggered(const QByteArray &propertyName, const QVariant &propertyValue) +void ClientProxy::objectWatchTriggered(int objectDebugId, + const QByteArray &propertyName, + const QVariant &propertyValue) { - // is flooding the debugging output log! - // log(LogReceive, QString("UPDATE_WATCH %1 %2").arg(QString::fromAscii(propertyName), propertyValue.toString())); - - QDeclarativeDebugWatch *watch = dynamic_cast(QObject::sender()); - if (watch) - emit propertyChanged(watch->objectDebugId(),propertyName, propertyValue); + if (m_objectWatches.contains(objectDebugId)) + emit propertyChanged(objectDebugId, propertyName, propertyValue); } bool ClientProxy::removeObjectWatch(int objectDebugId) @@ -403,29 +426,19 @@ bool ClientProxy::removeObjectWatch(int objectDebugId) if (objectDebugId == -1) return false; - if (!m_objectWatches.keys().contains(objectDebugId)) + if (!m_objectWatches.contains(objectDebugId)) return false; if (!isConnected()) return false; - QDeclarativeDebugWatch *watch = m_objectWatches.value(objectDebugId); - disconnect(watch,SIGNAL(valueChanged(QByteArray,QVariant)), this, SLOT(objectWatchTriggered(QByteArray,QVariant))); - - // is flooding the debugging output log! - // log(LogSend, QString("NO_WATCH %1").arg(QString::number(objectDebugId))); - - m_engineClient->removeWatch(watch); - delete watch; - m_objectWatches.remove(objectDebugId); - - + m_objectWatches.removeOne(objectDebugId); return true; } void ClientProxy::removeAllObjectWatches() { - foreach (int watchedObject, m_objectWatches.keys()) + foreach (int watchedObject, m_objectWatches) removeObjectWatch(watchedObject); } @@ -437,87 +450,75 @@ void ClientProxy::queryEngineContext(int id) if (!isConnected()) return; - if (m_contextQuery) { - delete m_contextQuery; - m_contextQuery = 0; - } + if (m_contextQueryId) + m_contextQueryId = 0; log(LogSend, QString("LIST_OBJECTS %1").arg(QString::number(id))); - m_contextQuery = m_engineClient->queryRootContexts(QDeclarativeDebugEngineReference(id), - m_engineClient); - if (!m_contextQuery->isWaiting()) - contextChanged(); - else - connect(m_contextQuery, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)), - this, SLOT(contextChanged())); + m_contextQueryId = m_engineClient->queryRootContexts(QmlDebugEngineReference(id)); } -void ClientProxy::contextChanged() +void ClientProxy::contextChanged(const QVariant &value) { log(LogReceive, QString("LIST_OBJECTS_R")); - if (m_contextQuery) { + if (m_contextQueryId) { m_rootObjects.clear(); - QDeclarativeDebugContextReference rootContext = m_contextQuery->rootContext(); - delete m_contextQuery; - m_contextQuery = 0; + QmlDebugContextReference rootContext = + qvariant_cast(value); + m_contextQueryId = 0; - qDeleteAll(m_objectTreeQuery); - m_objectTreeQuery.clear(); + m_objectTreeQueryIds.clear(); m_requestObjectsTimer.stop(); fetchContextObjectRecursive(rootContext); } } -void ClientProxy::fetchContextObjectRecursive(const QDeclarativeDebugContextReference& context) +void ClientProxy::fetchContextObjectRecursive( + const QmlDebugContextReference& context) { if (!isConnected()) return; - foreach (const QDeclarativeDebugObjectReference & obj, context.objects()) { + foreach (const QmlDebugObjectReference & obj, context.objects()) { log(LogSend, QString("FETCH_OBJECT %1").arg(obj.idString())); - QDeclarativeDebugObjectQuery* query - = m_engineClient->queryObjectRecursive(obj, m_engineClient); - if (!query->isWaiting()) { - query->deleteLater(); //ignore errors; - } else { - m_objectTreeQuery << query; - connect(query, - SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)), - SLOT(objectTreeFetched(QmlJsDebugClient::QDeclarativeDebugQuery::State))); - } + quint32 queryId = m_engineClient->queryObjectRecursive(obj); + if (queryId) + m_objectTreeQueryIds << queryId; } - foreach (const QDeclarativeDebugContextReference& child, context.contexts()) { + foreach (const QmlDebugContextReference& child, context.contexts()) { fetchContextObjectRecursive(child); } } - -void ClientProxy::objectTreeFetched(QmlJsDebugClient::QDeclarativeDebugQuery::State state) +void ClientProxy::onResult(quint32 queryId, const QVariant &value) { - QDeclarativeDebugObjectQuery *query = qobject_cast(sender()); - if (!query || state == QDeclarativeDebugQuery::Error) { - delete query; - return; - } + if (m_objectTreeQueryIds.contains(queryId)) + objectTreeFetched(queryId, value); + else if (queryId == m_engineQueryId) + updateEngineList(value); + else if (queryId == m_contextQueryId) + contextChanged(value); + else + emit result(queryId, value); +} - log(LogReceive, QString("FETCH_OBJECT_R %1").arg(query->object().idString())); +void ClientProxy::objectTreeFetched(quint32 queryId, const QVariant &result) +{ + QmlDebugObjectReference obj = qvariant_cast(result); - m_rootObjects.append(query->object()); + log(LogReceive, QString("FETCH_OBJECT_R %1").arg(obj.idString())); - int removed = m_objectTreeQuery.removeAll(query); - Q_ASSERT(removed == 1); - Q_UNUSED(removed); - delete query; + m_rootObjects.append(obj); - if (m_objectTreeQuery.isEmpty()) { + m_objectTreeQueryIds.removeOne(queryId); + if (m_objectTreeQueryIds.isEmpty()) { int old_count = m_debugIdHash.count(); m_debugIdHash.clear(); m_debugIdHash.reserve(old_count + 1); - foreach (const QDeclarativeDebugObjectReference &it, m_rootObjects) + foreach (const QmlDebugObjectReference &it, m_rootObjects) buildDebugIdHashRecursive(it); emit objectTreeUpdated(); @@ -530,14 +531,15 @@ void ClientProxy::objectTreeFetched(QmlJsDebugClient::QDeclarativeDebugQuery::St } } -void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReference& ref) +void ClientProxy::buildDebugIdHashRecursive(const QmlDebugObjectReference& ref) { QUrl fileUrl = ref.source().url(); int lineNum = ref.source().lineNumber(); int colNum = ref.source().columnNumber(); int rev = 0; - // handle the case where the url contains the revision number encoded. (for object created by the debugger) + // handle the case where the url contains the revision number encoded. + //(for object created by the debugger) static QRegExp rx("(.*)_(\\d+):(\\d+)$"); if (rx.exactMatch(fileUrl.path())) { fileUrl.setPath(rx.cap(1)); @@ -548,9 +550,10 @@ void ClientProxy::buildDebugIdHashRecursive(const QDeclarativeDebugObjectReferen const QString filePath = InspectorUi::instance()->findFileInProject(fileUrl); // append the debug ids in the hash - m_debugIdHash[qMakePair(filePath, rev)][qMakePair(lineNum, colNum)].append(ref.debugId()); + m_debugIdHash[qMakePair(filePath, rev)][qMakePair( + lineNum, colNum)].append(ref.debugId()); - foreach (const QDeclarativeDebugObjectReference &it, ref.children()) + foreach (const QmlDebugObjectReference &it, ref.children()) buildDebugIdHashRecursive(it); } @@ -609,10 +612,12 @@ void ClientProxy::showAppOnTop(bool showOnTop) } void ClientProxy::createQmlObject(const QString &qmlText, int parentDebugId, - const QStringList &imports, const QString &filename, int order) + const QStringList &imports, + const QString &filename, int order) { if (isConnected()) - m_inspectorClient->createQmlObject(qmlText, parentDebugId, imports, filename, order); + m_inspectorClient->createQmlObject(qmlText, parentDebugId, imports, + filename, order); } void ClientProxy::destroyQmlObject(int debugId) @@ -629,8 +634,10 @@ void ClientProxy::reparentQmlObject(int debugId, int newParent) void ClientProxy::updateConnected() { - bool isConnected = m_inspectorClient && m_inspectorClient->status() == QDeclarativeDebugClient::Enabled - && m_engineClient && m_engineClient->status() == QDeclarativeDebugClient::Enabled; + bool isConnected = m_inspectorClient && + m_inspectorClient->status() == QDeclarativeDebugClient::Enabled && + m_engineClient && + m_engineClient->status() == QDeclarativeDebugClient::Enabled; if (isConnected != m_isConnected) { m_isConnected = isConnected; @@ -645,11 +652,6 @@ void ClientProxy::updateConnected() void ClientProxy::reloadEngines() { - if (m_engineQuery) { - emit connectionStatusMessage("[Inspector] Waiting for response to previous engine query"); - return; - } - if (!isConnected()) return; @@ -657,28 +659,20 @@ void ClientProxy::reloadEngines() log(LogSend, QString("LIST_ENGINES")); - m_engineQuery = m_engineClient->queryAvailableEngines(m_engineClient); - if (!m_engineQuery->isWaiting()) { - updateEngineList(); - } else { - connect(m_engineQuery, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)), - this, SLOT(updateEngineList())); - } + m_engineQueryId = m_engineClient->queryAvailableEngines(); } -QList ClientProxy::engines() const +QList ClientProxy::engines() const { return m_engines; } -void ClientProxy::updateEngineList() +void ClientProxy::updateEngineList(const QVariant &value) { log(LogReceive, QString("LIST_ENGINES_R")); - m_engines = m_engineQuery->engines(); - delete m_engineQuery; - m_engineQuery = 0; - + m_engines = qvariant_cast(value); + m_engineQueryId = 0; emit enginesChanged(); } diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index 98c446abe62..c893bb44c2d 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -60,16 +60,16 @@ public: explicit ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent = 0); ~ClientProxy(); - bool setBindingForObject(int objectDebugId, + quint32 setBindingForObject(int objectDebugId, const QString &propertyName, const QVariant &value, bool isLiteralValue, QString source, int line); - bool setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId, const QString &expr); + quint32 setMethodBodyForObject(int objectDebugId, const QString &methodName, const QString &methodBody); + quint32 resetBindingForObject(int objectDebugId, const QString &propertyName); + quint32 queryExpressionResult(int objectDebugId, const QString &expr); void clearComponentCache(); bool addObjectWatch(int objectDebugId); @@ -77,19 +77,19 @@ public: void removeAllObjectWatches(); // returns the object references - QList objectReferences() const; - QDeclarativeDebugObjectReference objectReferenceForId(int debugId) const; - QDeclarativeDebugObjectReference objectReferenceForId(const QString &objectId) const; - QDeclarativeDebugObjectReference objectReferenceForLocation(const int line, const int column) const; - QList rootObjectReference() const; + QList objectReferences() const; + QmlDebugObjectReference objectReferenceForId(int debugId) const; + QmlDebugObjectReference objectReferenceForId(const QString &objectId) const; + QmlDebugObjectReference objectReferenceForLocation(const int line, const int column) const; + QList rootObjectReference() const; DebugIdHash debugIdHash() const { return m_debugIdHash; } bool isConnected() const; void setSelectedItemsByDebugId(const QList &debugIds); - void setSelectedItemsByObjectId(const QList &objectRefs); + void setSelectedItemsByObjectId(const QList &objectRefs); - QList engines() const; + QList engines() const; Debugger::QmlAdapter *qmlAdapter() const; @@ -100,7 +100,7 @@ signals: void aboutToReloadEngines(); void enginesChanged(); - void selectedItemsChanged(const QList &selectedItems); + void selectedItemsChanged(const QList &selectedItems); void connected(); void disconnected(); @@ -117,6 +117,8 @@ signals: void selectedColorChanged(const QColor &color); void propertyChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue); + void result(quint32 queryId, const QVariant &result); + public slots: void refreshObjectTree(); void queryEngineContext(int id); @@ -140,21 +142,21 @@ private slots: void clientStatusChanged(QDeclarativeDebugClient::Status status); void engineClientStatusChanged(QDeclarativeDebugClient::Status status); - void contextChanged(); - void onCurrentObjectsChanged(const QList &debugIds, bool requestIfNeeded = true); - void updateEngineList(); - void objectTreeFetched(QmlJsDebugClient::QDeclarativeDebugQuery::State state = QmlJsDebugClient::QDeclarativeDebugQuery::Completed); - void fetchContextObjectRecursive(const QmlJsDebugClient::QDeclarativeDebugContextReference& context); + void fetchContextObjectRecursive(const QmlDebugContextReference &context); void newObjects(); - void objectWatchTriggered(const QByteArray &propertyName, const QVariant &propertyValue); + void objectWatchTriggered(int debugId, const QByteArray &propertyName, const QVariant &propertyValue); + void onResult(quint32 queryId, const QVariant &result); private: + void contextChanged(const QVariant &value); + void updateEngineList(const QVariant &value); + void objectTreeFetched(quint32 queryId, const QVariant &result); void updateConnected(); void reloadEngines(); - QList objectReferences(const QDeclarativeDebugObjectReference &objectRef) const; - QDeclarativeDebugObjectReference objectReferenceForId(int debugId, const QDeclarativeDebugObjectReference &ref) const; + QList objectReferences(const QmlDebugObjectReference &objectRef) const; + QmlDebugObjectReference objectReferenceForId(int debugId, const QmlDebugObjectReference &ref) const; enum LogDirection { LogSend, @@ -164,22 +166,22 @@ private: private: - void buildDebugIdHashRecursive(const QDeclarativeDebugObjectReference &ref); + void buildDebugIdHashRecursive(const QmlDebugObjectReference &ref); QWeakPointer m_adapter; QmlEngineDebugClient *m_engineClient; QmlJSInspectorClient *m_inspectorClient; - QDeclarativeDebugEnginesQuery *m_engineQuery; - QDeclarativeDebugRootContextQuery *m_contextQuery; - QList m_objectTreeQuery; + quint32 m_engineQueryId; + quint32 m_contextQueryId; + QList m_objectTreeQueryIds; - QList m_rootObjects; - QList m_engines; + QList m_rootObjects; + QmlDebugEngineReferenceList m_engines; QTimer m_requestObjectsTimer; DebugIdHash m_debugIdHash; - QHash m_objectWatches; + QList m_objectWatches; bool m_isConnected; }; diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index f499111533b..73a1cfb9c49 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -224,7 +224,7 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE if (!qmlNode) return; - QDeclarativeDebugObjectReference ref; + QmlDebugObjectReference ref; if (QmlJS::AST::Node *node = qmlEditor->semanticInfo().declaringMemberNoProperties(cursorPos)) { if (QmlJS::AST::UiObjectMember *objMember = node->uiObjectMemberCast()) { @@ -249,7 +249,7 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE if ((qmlNode->kind == QmlJS::AST::Node::Kind_IdentifierExpression) && (m_clientProxy->objectReferenceForId(refToLook).debugId() == -1)) { query = doubleQuote + QString("local: ") + refToLook + doubleQuote; - foreach (const QDeclarativeDebugPropertyReference &property, ref.properties()) { + foreach (const QmlDebugPropertyReference &property, ref.properties()) { if (property.name() == wordAtCursor && !property.valueTypeName().isEmpty()) { query = doubleQuote + property.name() + QLatin1Char(':') @@ -263,7 +263,7 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE + QLatin1Char('+') + refToLook; } else { // show properties - foreach (const QDeclarativeDebugPropertyReference &property, ref.properties()) { + foreach (const QmlDebugPropertyReference &property, ref.properties()) { if (property.name() == wordAtCursor && !property.valueTypeName().isEmpty()) { query = doubleQuote + property.name() + QLatin1Char(':') + doubleQuote + QLatin1Char('+') + property.name(); @@ -275,25 +275,19 @@ void InspectorUi::showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextE if (!query.isEmpty()) { m_debugQuery = m_clientProxy->queryExpressionResult(ref.debugId(), query); - connect(m_debugQuery, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)), - this, SLOT(debugQueryUpdated(QmlJsDebugClient::QDeclarativeDebugQuery::State))); } } } -void InspectorUi::debugQueryUpdated(QmlJsDebugClient::QDeclarativeDebugQuery::State newState) +void InspectorUi::onResult(quint32 queryId, const QVariant &result) { - if (newState != QDeclarativeDebugExpressionQuery::Completed) - return; - if (!m_debugQuery) + if (m_debugQuery != queryId) return; - QString text = m_debugQuery->result().toString(); + m_debugQuery = 0; + QString text = result.toString(); if (!text.isEmpty()) QToolTip::showText(QCursor::pos(), text); - - disconnect(m_debugQuery, SIGNAL(stateChanged(QmlJsDebugClient::QDeclarativeDebugQuery::State)), - this, SLOT(debugQueryUpdated(QmlJsDebugClient::QDeclarativeDebugQuery::State))); } bool InspectorUi::isConnected() const @@ -303,7 +297,13 @@ bool InspectorUi::isConnected() const void InspectorUi::connected(ClientProxy *clientProxy) { + if (m_clientProxy) + disconnect(m_clientProxy, SIGNAL(result(quint32,QVariant)), + this, SLOT(onResult(quint32,QVariant))); m_clientProxy = clientProxy; + if (m_clientProxy) + connect(m_clientProxy, SIGNAL(result(quint32,QVariant)), + SLOT(onResult(quint32,QVariant))); QmlJS::Snapshot snapshot = modelManager()->snapshot(); for (QHash::const_iterator it = m_textPreviews.constBegin(); @@ -365,19 +365,19 @@ void InspectorUi::objectTreeReady() void InspectorUi::updateEngineList() { - QList engines = m_clientProxy->engines(); + QList engines = m_clientProxy->engines(); //#warning update the QML engines combo if (engines.isEmpty()) qWarning("qmldebugger: no engines found!"); else { - const QDeclarativeDebugEngineReference engine = engines.first(); + const QmlDebugEngineReference engine = engines.first(); m_clientProxy->queryEngineContext(engine.debugId()); } } -void InspectorUi::changeSelectedItems(const QList &objects) +void InspectorUi::changeSelectedItems(const QList &objects) { if (m_selectionCallbackExpected) { m_selectionCallbackExpected = false; @@ -386,9 +386,9 @@ void InspectorUi::changeSelectedItems(const QList realList; - foreach (const QDeclarativeDebugObjectReference &obj, objects) { - QDeclarativeDebugObjectReference clientRef = m_clientProxy->objectReferenceForId(obj.debugId()); + QList realList; + foreach (const QmlDebugObjectReference &obj, objects) { + QmlDebugObjectReference clientRef = m_clientProxy->objectReferenceForId(obj.debugId()); realList << clientRef; } @@ -476,8 +476,8 @@ QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEdit } else { preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy, this); connect(preview, - SIGNAL(selectedItemsChanged(QList)), - SLOT(changeSelectedItems(QList))); + SIGNAL(selectedItemsChanged(QList)), + SLOT(changeSelectedItems(QList))); connect(preview, SIGNAL(reloadQmlViewerRequested()), m_clientProxy, SLOT(reloadQmlViewer())); connect(preview, SIGNAL(disableLivePreviewRequested()), SLOT(disableLivePreview())); @@ -503,36 +503,36 @@ void InspectorUi::reloadQmlViewer() m_clientProxy->reloadQmlViewer(); } -inline QDeclarativeDebugObjectReference findParentRecursive( int goalDebugId, - const QList< QDeclarativeDebugObjectReference > &objectsToSearch) +inline QmlDebugObjectReference findParentRecursive( int goalDebugId, + const QList &objectsToSearch) { if (goalDebugId == -1) - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); - foreach (const QDeclarativeDebugObjectReference &possibleParent, objectsToSearch) { + foreach (const QmlDebugObjectReference &possibleParent, objectsToSearch) { // Am I a root object? No parent if ( possibleParent.debugId() == goalDebugId ) - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); // Is the goal one of my children? - foreach (const QDeclarativeDebugObjectReference &child, possibleParent.children()) + foreach (const QmlDebugObjectReference &child, possibleParent.children()) if ( child.debugId() == goalDebugId ) return possibleParent; // no luck? pass this on - QDeclarativeDebugObjectReference candidate = findParentRecursive(goalDebugId, possibleParent.children()); + QmlDebugObjectReference candidate = findParentRecursive(goalDebugId, possibleParent.children()); if (candidate.debugId() != -1) return candidate; } - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); } -inline QString displayName(const QDeclarativeDebugObjectReference &obj) +inline QString displayName(const QmlDebugObjectReference &obj) { // special! state names if (obj.className() == "State") { - foreach (const QDeclarativeDebugPropertyReference &prop, obj.properties()) { + foreach (const QmlDebugPropertyReference &prop, obj.properties()) { if (prop.name() == "name") return prop.value().toString(); } @@ -551,16 +551,16 @@ inline QString displayName(const QDeclarativeDebugObjectReference &obj) return QString("<%1>").arg(objTypeName); } -void InspectorUi::selectItems(const QList &objectReferences) +void InspectorUi::selectItems(const QList &objectReferences) { - foreach (const QDeclarativeDebugObjectReference &objref, objectReferences) { + foreach (const QmlDebugObjectReference &objref, objectReferences) { int debugId = objref.debugId(); if (debugId != -1) { // select only the first valid element of the list m_clientProxy->removeAllObjectWatches(); m_clientProxy->addObjectWatch(debugId); - QList selectionList; + QList selectionList; selectionList << objref; m_propertyInspector->setCurrentObjects(selectionList); populateCrumblePath(objref); @@ -574,21 +574,21 @@ void InspectorUi::selectItems(const QList &obj } } -bool InspectorUi::isRoot(const QDeclarativeDebugObjectReference &obj) const +bool InspectorUi::isRoot(const QmlDebugObjectReference &obj) const { - foreach (const QDeclarativeDebugObjectReference &rootObj, m_clientProxy->rootObjectReference()) + foreach (const QmlDebugObjectReference &rootObj, m_clientProxy->rootObjectReference()) if (obj.debugId() == rootObj.debugId()) return true; return false; } -void InspectorUi::populateCrumblePath(const QDeclarativeDebugObjectReference &objRef) +void InspectorUi::populateCrumblePath(const QmlDebugObjectReference &objRef) { QStringList crumbleStrings; QList crumbleData; // first find path by climbing the hierarchy - QDeclarativeDebugObjectReference ref = objRef; + QmlDebugObjectReference ref = objRef; crumbleData << objRef.debugId(); crumbleStrings << displayName(objRef); @@ -603,7 +603,7 @@ void InspectorUi::populateCrumblePath(const QDeclarativeDebugObjectReference &ob crumbleData.clear(); // now append the children - foreach (const QDeclarativeDebugObjectReference &child, objRef.children()) { + foreach (const QmlDebugObjectReference &child, objRef.children()) { crumbleData.push_back(child.debugId()); crumbleStrings.push_back( displayName(child) ); } @@ -613,10 +613,10 @@ void InspectorUi::populateCrumblePath(const QDeclarativeDebugObjectReference &ob void InspectorUi::selectItems(const QList &objectIds) { - QList objectReferences; + QList objectReferences; foreach (int objectId, objectIds) { - QDeclarativeDebugObjectReference ref = m_clientProxy->objectReferenceForId(objectId); + QmlDebugObjectReference ref = m_clientProxy->objectReferenceForId(objectId); if (ref.debugId() == objectId) objectReferences.append(ref); } @@ -646,7 +646,7 @@ void InspectorUi::disable() m_filterExp->setEnabled(false); } -QDeclarativeDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const +QmlDebugObjectReference InspectorUi::objectReferenceForLocation(const QString &fileName, int cursorPosition) const { Core::EditorManager *editorManager = Core::EditorManager::instance(); Core::IEditor *editor = editorManager->openEditor(fileName); @@ -667,17 +667,17 @@ QDeclarativeDebugObjectReference InspectorUi::objectReferenceForLocation(const Q } } } - return QDeclarativeDebugObjectReference(); + return QmlDebugObjectReference(); } -void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj) +void InspectorUi::gotoObjectReferenceDefinition(const QmlDebugObjectReference &obj) { if (m_cursorPositionChangedExternally) { m_cursorPositionChangedExternally = false; return; } - QDeclarativeDebugFileReference source = obj.source(); + QmlDebugFileReference source = obj.source(); const QString fileName = m_projectFinder.findFile(source.url()); @@ -690,7 +690,7 @@ void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectRef m_selectionCallbackExpected = true; if (textEditor) { - QDeclarativeDebugObjectReference ref = objectReferenceForLocation(fileName); + QmlDebugObjectReference ref = objectReferenceForLocation(fileName); if (ref.debugId() != obj.debugId()) { m_selectionCallbackExpected = true; editorManager->addCurrentPositionToNavigationHistory(); @@ -843,8 +843,8 @@ void InspectorUi::connectSignals() connect(m_clientProxy, SIGNAL(propertyChanged(int,QByteArray,QVariant)), m_propertyInspector, SLOT(propertyValueChanged(int,QByteArray,QVariant))); - connect(m_clientProxy, SIGNAL(selectedItemsChanged(QList)), - this, SLOT(selectItems(QList))); + connect(m_clientProxy, SIGNAL(selectedItemsChanged(QList)), + this, SLOT(selectItems(QList))); connect(m_clientProxy, SIGNAL(enginesChanged()), this, SLOT(updateEngineList())); connect(m_clientProxy, SIGNAL(serverReloaded()), diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index 6a9544f55ac..7514bd9a009 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -112,14 +112,15 @@ public slots: void reloadQmlViewer(); void serverReloaded(); void setApplyChangesToQmlInspector(bool applyChanges); + void onResult(quint32 queryId, const QVariant &result); private slots: void enable(); void disable(); - void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj); - void selectItems(const QList &objectReferences); + void gotoObjectReferenceDefinition(const QmlDebugObjectReference &obj); + void selectItems(const QList &objectReferences); void selectItems(const QList &objectIds); - void changeSelectedItems(const QList &objects); + void changeSelectedItems(const QList &objects); void changePropertyValue(int debugId,const QString &propertyName, const QString &valueExpression); void objectTreeReady(); @@ -133,7 +134,6 @@ private slots: void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc); void showDebuggerTooltip(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos); - void debugQueryUpdated(QmlJsDebugClient::QDeclarativeDebugQuery::State); private: bool addQuotesForData(const QVariant &value) const; @@ -143,9 +143,9 @@ private: void applyChangesToQmlInspectorHelper(bool applyChanges); void setupDockWidgets(); QString filenameForShadowBuildFile(const QString &filename) const; - void populateCrumblePath(const QDeclarativeDebugObjectReference &objRef); - bool isRoot(const QDeclarativeDebugObjectReference &obj) const; - QDeclarativeDebugObjectReference objectReferenceForLocation(const QString &fileName, int cursorPosition=-1) const; + void populateCrumblePath(const QmlDebugObjectReference &objRef); + bool isRoot(const QmlDebugObjectReference &obj) const; + QmlDebugObjectReference objectReferenceForLocation(const QString &fileName, int cursorPosition=-1) const; void connectSignals(); void disconnectSignals(); @@ -160,7 +160,7 @@ private: InspectorSettings *m_settings; ClientProxy *m_clientProxy; QObject *m_qmlEngine; - QDeclarativeDebugExpressionQuery *m_debugQuery; + quint32 m_debugQuery; // Qml/JS integration QHash m_textPreviews; diff --git a/src/plugins/qmljsinspector/qmljsinspectorclient.cpp b/src/plugins/qmljsinspector/qmljsinspectorclient.cpp index d4bf615c8ce..45e52603cc1 100644 --- a/src/plugins/qmljsinspector/qmljsinspectorclient.cpp +++ b/src/plugins/qmljsinspector/qmljsinspectorclient.cpp @@ -182,15 +182,15 @@ void QmlJSInspectorClient::setCurrentObjects(const QList &debugIds) sendMessage(message); } -void recurseObjectIdList(const QDeclarativeDebugObjectReference &ref, QList &debugIds, QList &objectIds) +void recurseObjectIdList(const QmlDebugObjectReference &ref, QList &debugIds, QList &objectIds) { debugIds << ref.debugId(); objectIds << ref.idString(); - foreach (const QDeclarativeDebugObjectReference &child, ref.children()) + foreach (const QmlDebugObjectReference &child, ref.children()) recurseObjectIdList(child, debugIds, objectIds); } -void QmlJSInspectorClient::setObjectIdList(const QList &objectRoots) +void QmlJSInspectorClient::setObjectIdList(const QList &objectRoots) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); @@ -198,7 +198,7 @@ void QmlJSInspectorClient::setObjectIdList(const QList debugIds; QList objectIds; - foreach (const QDeclarativeDebugObjectReference &ref, objectRoots) + foreach (const QmlDebugObjectReference &ref, objectRoots) recurseObjectIdList(ref, debugIds, objectIds); InspectorProtocol::Message cmd = InspectorProtocol::ObjectIdList; diff --git a/src/plugins/qmljsinspector/qmljsinspectorclient.h b/src/plugins/qmljsinspector/qmljsinspectorclient.h index f090841fbdb..94ae980bd08 100644 --- a/src/plugins/qmljsinspector/qmljsinspectorclient.h +++ b/src/plugins/qmljsinspector/qmljsinspectorclient.h @@ -68,7 +68,7 @@ public: QList currentObjects() const; // ### Qt 4.8: remove if we can have access to qdeclarativecontextdata or id's - void setObjectIdList(const QList &objectRoots); + void setObjectIdList(const QList &objectRoots); void clearComponentCache(); diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp index 17eed26cde0..07ec76ad915 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp @@ -220,7 +220,7 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList offsets, const QStr if (m_editors.isEmpty() || !m_previousDoc || !m_clientProxy) return; - QDeclarativeDebugObjectReference objectRefUnderCursor; + QmlDebugObjectReference objectRefUnderCursor; objectRefUnderCursor = m_clientProxy.data()->objectReferenceForId(wordAtCursor); QList selectedReferences; @@ -252,20 +252,20 @@ void QmlJSLiveTextPreview::changeSelectedElements(QList offsets, const QStr } if (!selectedReferences.isEmpty()) { - QList refs; + QList refs; foreach(int i, selectedReferences) - refs << QDeclarativeDebugObjectReference(i); + refs << QmlDebugObjectReference(i); emit selectedItemsChanged(refs); } } -static QList findRootObjectRecursive(const QDeclarativeDebugObjectReference &object, const Document::Ptr &doc) +static QList findRootObjectRecursive(const QmlDebugObjectReference &object, const Document::Ptr &doc) { QList result; if (object.className() == doc->componentName()) result += object.debugId(); - foreach (const QDeclarativeDebugObjectReference &it, object.children()) { + foreach (const QmlDebugObjectReference &it, object.children()) { result += findRootObjectRecursive(it, doc); } return result; @@ -305,7 +305,7 @@ void QmlJSLiveTextPreview::updateDebugIds() if(doc->qmlProgram()->members && doc->qmlProgram()->members->member) { UiObjectMember* root = doc->qmlProgram()->members->member; QList r; - foreach(const QDeclarativeDebugObjectReference& it, clientProxy->rootObjectReference()) + foreach (const QmlDebugObjectReference& it, clientProxy->rootObjectReference()) r += findRootObjectRecursive(it, doc); if (!r.isEmpty()) m_debugIds[root] += r; @@ -464,7 +464,10 @@ protected: if (isLiteral) expr = castToLiteral(scriptCode, scriptBinding); appliedChangesToViewer = true; - m_clientProxy->setBindingForObject(debugId, propertyName, expr, isLiteral, document()->fileName(), scriptBinding->firstSourceLocation().startLine); + m_clientProxy->setBindingForObject( + debugId, propertyName, expr, + isLiteral, document()->fileName(), + scriptBinding->firstSourceLocation().startLine); } virtual void resetBindingForObject(int debugId, const QString &propertyName) diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.h b/src/plugins/qmljsinspector/qmljslivetextpreview.h index 661b2d0e771..50691593262 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.h +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.h @@ -72,8 +72,8 @@ public: void associateEditor(Core::IEditor *editor); void unassociateEditor(Core::IEditor *editor); - void setActiveObject(const QDeclarativeDebugObjectReference &object); - void mapObjectToQml(const QDeclarativeDebugObjectReference &object); + void setActiveObject(const QmlDebugObjectReference &object); + void mapObjectToQml(const QmlDebugObjectReference &object); void resetInitialDoc(const QmlJS::Document::Ptr &doc); void setClientProxy(ClientProxy *clientProxy); @@ -85,7 +85,7 @@ public: }; signals: - void selectedItemsChanged(const QList &objects); + void selectedItemsChanged(const QList &objects); void reloadQmlViewerRequested(); void disableLivePreviewRequested(); diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp index 4ee78abf2a0..412b3b7511e 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.cpp +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.cpp @@ -295,14 +295,14 @@ void QmlJSPropertyInspector::clear() m_currentObjects.clear(); } -void QmlJSPropertyInspector::setCurrentObjects(const QList &objectList) +void QmlJSPropertyInspector::setCurrentObjects(const QList &objectList) { if (objectList.isEmpty()) return; clear(); - foreach (const QDeclarativeDebugObjectReference &obj, objectList) { + foreach (const QmlDebugObjectReference &obj, objectList) { m_currentObjects << obj.debugId(); buildPropertyTree(obj); } @@ -350,7 +350,7 @@ void QmlJSPropertyInspector::propertyValueEdited(const int objectId,const QStrin emit changePropertyValue(objectId, propertyName, propertyValue); } -void QmlJSPropertyInspector::buildPropertyTree(const QDeclarativeDebugObjectReference &obj) +void QmlJSPropertyInspector::buildPropertyTree(const QmlDebugObjectReference &obj) { // Strip off the misleading metadata QString objTypeName = obj.className(); @@ -375,7 +375,7 @@ void QmlJSPropertyInspector::buildPropertyTree(const QDeclarativeDebugObjectRefe false); } - foreach (const QDeclarativeDebugPropertyReference &prop, obj.properties()) { + foreach (const QmlDebugPropertyReference &prop, obj.properties()) { QString propertyName = prop.name(); QString propertyValue = prop.value().toString(); diff --git a/src/plugins/qmljsinspector/qmljspropertyinspector.h b/src/plugins/qmljsinspector/qmljspropertyinspector.h index 31fe1d61b62..7962e55ae25 100644 --- a/src/plugins/qmljsinspector/qmljspropertyinspector.h +++ b/src/plugins/qmljsinspector/qmljspropertyinspector.h @@ -129,7 +129,7 @@ signals: void customContextMenuRequested(const QPoint &pos); public slots: - void setCurrentObjects(const QList &); + void setCurrentObjects(const QList &); void propertyValueEdited(const int objectId,const QString &propertyName, const QString &propertyValue); void propertyValueChanged(int debugId, const QByteArray &propertyName, const QVariant &propertyValue); void filterBy(const QString &expression); @@ -139,7 +139,7 @@ public slots: private: friend class PropertyEditDelegate; - void buildPropertyTree(const QDeclarativeDebugObjectReference &); + void buildPropertyTree(const QmlDebugObjectReference &); void addRow(const QString &name, const QString &value, const QString &type, const int debugId = -1, bool editable = true); void setColorIcon(int row);