aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-03-06 17:25:58 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-19 14:35:54 +0100
commitbfedb27838864e7acddebc6c0f731d617c3d1c22 (patch)
tree9f3eab3db7aa06004ccf148b74522ecdf0cda5b0 /src
parente0e81d6f20e2190becd6354785a148c147f00ad8 (diff)
QmlEngineDebugService: Rename service to QmlDebugger
Rename service from QDeclarativeEngine to QmlDebugger. Send a response for each query. Change-Id: I01cfeaf3e4116bfd7029d170ee228c159973947c Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/debugger/qqmlenginedebugservice.cpp86
-rw-r--r--src/qml/debugger/qqmlenginedebugservice_p.h6
-rw-r--r--src/qml/qml/qqmlwatcher.cpp5
-rw-r--r--src/qml/qml/qqmlwatcher_p.h2
4 files changed, 58 insertions, 41 deletions
diff --git a/src/qml/debugger/qqmlenginedebugservice.cpp b/src/qml/debugger/qqmlenginedebugservice.cpp
index a89e94c1b8..40af773c68 100644
--- a/src/qml/debugger/qqmlenginedebugservice.cpp
+++ b/src/qml/debugger/qqmlenginedebugservice.cpp
@@ -67,7 +67,7 @@ QQmlEngineDebugService *QQmlEngineDebugService::instance()
}
QQmlEngineDebugService::QQmlEngineDebugService(QObject *parent)
- : QQmlDebugService(QStringLiteral("QDeclarativeEngine"), 1, parent),
+ : QQmlDebugService(QStringLiteral("QmlDebugger"), 1, parent),
m_watch(new QQmlWatcher(this)),
m_statesDelegate(0)
{
@@ -396,12 +396,10 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
QDataStream ds(message);
QByteArray type;
- ds >> type;
+ int queryId;
+ ds >> type >> queryId;
if (type == "LIST_ENGINES") {
- int queryId;
- ds >> queryId;
-
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
rs << QByteArray("LIST_ENGINES_R");
@@ -418,9 +416,8 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
sendMessage(reply);
} else if (type == "LIST_OBJECTS") {
- int queryId;
int engineId = -1;
- ds >> queryId >> engineId;
+ ds >> engineId;
QQmlEngine *engine =
qobject_cast<QQmlEngine *>(QQmlDebugService::objectForId(engineId));
@@ -445,12 +442,11 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
sendMessage(reply);
} else if (type == "FETCH_OBJECT") {
- int queryId;
int objectId;
bool recurse;
bool dumpProperties = true;
- ds >> queryId >> objectId >> recurse >> dumpProperties;
+ ds >> objectId >> recurse >> dumpProperties;
QObject *object = QQmlDebugService::objectForId(objectId);
@@ -466,10 +462,9 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
sendMessage(reply);
} else if (type == "WATCH_OBJECT") {
- int queryId;
int objectId;
- ds >> queryId >> objectId;
+ ds >> objectId;
bool ok = m_watch->addWatch(queryId, objectId);
QByteArray reply;
@@ -478,11 +473,10 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
sendMessage(reply);
} else if (type == "WATCH_PROPERTY") {
- int queryId;
int objectId;
QByteArray property;
- ds >> queryId >> objectId >> property;
+ ds >> objectId >> property;
bool ok = m_watch->addWatch(queryId, objectId, property);
QByteArray reply;
@@ -491,11 +485,10 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
sendMessage(reply);
} else if (type == "WATCH_EXPR_OBJECT") {
- int queryId;
int debugId;
QString expr;
- ds >> queryId >> debugId >> expr;
+ ds >> debugId >> expr;
bool ok = m_watch->addWatch(queryId, debugId, expr);
QByteArray reply;
@@ -503,16 +496,17 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok;
sendMessage(reply);
} else if (type == "NO_WATCH") {
- int queryId;
+ bool ok = m_watch->removeWatch(queryId);
- ds >> queryId;
- m_watch->removeWatch(queryId);
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("NO_WATCH_R") << queryId << ok;
+ sendMessage(reply);
} else if (type == "EVAL_EXPRESSION") {
- int queryId;
int objectId;
QString expr;
- ds >> queryId >> objectId >> expr;
+ ds >> objectId >> expr;
QObject *object = QQmlDebugService::objectForId(objectId);
QQmlContext *context = qmlContext(object);
@@ -541,26 +535,43 @@ void QQmlEngineDebugService::processMessage(const QByteArray &message)
bool isLiteralValue;
QString filename;
int line;
- ds >> objectId >> propertyName >> expr >> isLiteralValue;
- if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
- ds >> filename >> line;
- }
- setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
+ ds >> objectId >> propertyName >> expr >> isLiteralValue >>
+ filename >> line;
+ bool ok = setBinding(objectId, propertyName, expr, isLiteralValue,
+ filename, line);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("SET_BINDING_R") << queryId << ok;
+
+ sendMessage(reply);
} else if (type == "RESET_BINDING") {
int objectId;
QString propertyName;
ds >> objectId >> propertyName;
- resetBinding(objectId, propertyName);
+ bool ok = resetBinding(objectId, propertyName);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("RESET_BINDING_R") << queryId << ok;
+
+ sendMessage(reply);
} else if (type == "SET_METHOD_BODY") {
int objectId;
QString methodName;
QString methodBody;
ds >> objectId >> methodName >> methodBody;
- setMethodBody(objectId, methodName, methodBody);
+ bool ok = setMethodBody(objectId, methodName, methodBody);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("SET_METHOD_BODY_R") << queryId << ok;
+
+ sendMessage(reply);
}
}
-void QQmlEngineDebugService::setBinding(int objectId,
+bool QQmlEngineDebugService::setBinding(int objectId,
const QString &propertyName,
const QVariant &expression,
bool isLiteralValue,
@@ -568,6 +579,7 @@ void QQmlEngineDebugService::setBinding(int objectId,
int line,
int column)
{
+ bool ok = true;
QObject *object = objectForId(objectId);
QQmlContext *context = qmlContext(object);
@@ -596,22 +608,23 @@ void QQmlEngineDebugService::setBinding(int objectId,
oldBinding->destroy();
binding->update();
} else {
+ ok = false;
qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
}
}
} else {
// not a valid property
- bool ok = false;
if (m_statesDelegate)
ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue);
if (!ok)
qWarning() << "QQmlEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
}
}
+ return ok;
}
-void QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyName)
+bool QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyName)
{
QObject *object = objectForId(objectId);
QQmlContext *context = qmlContext(object);
@@ -653,24 +666,25 @@ void QQmlEngineDebugService::resetBinding(int objectId, const QString &propertyN
m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
}
}
+ return true;
}
-void QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
+bool QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
{
QObject *object = objectForId(objectId);
QQmlContext *context = qmlContext(object);
if (!object || !context || !context->engine())
- return;
+ return false;
QQmlContextData *contextData = QQmlContextData::get(context);
if (!contextData)
- return;
+ return false;
QQmlPropertyData dummy;
QQmlPropertyData *prop =
QQmlPropertyCache::property(context->engine(), object, method, dummy);
if (!prop || !prop->isVMEFunction())
- return;
+ return false;
QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
QList<QByteArray> paramNames = metaMethod.parameterNames();
@@ -692,6 +706,7 @@ void QQmlEngineDebugService::setMethodBody(int objectId, const QString &method,
int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
vmeMetaObject->setVmeMethod(prop->coreIndex, QQmlExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
+ return true;
}
void QQmlEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
@@ -731,7 +746,8 @@ void QQmlEngineDebugService::objectCreated(QQmlEngine *engine, QObject *object)
QByteArray reply;
QDataStream rs(&reply, QIODevice::WriteOnly);
- rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
+ //unique queryId -1
+ rs << QByteArray("OBJECT_CREATED") << -1 << engineId << objectId;
sendMessage(reply);
}
diff --git a/src/qml/debugger/qqmlenginedebugservice_p.h b/src/qml/debugger/qqmlenginedebugservice_p.h
index f41063d7a3..19a5776e27 100644
--- a/src/qml/debugger/qqmlenginedebugservice_p.h
+++ b/src/qml/debugger/qqmlenginedebugservice_p.h
@@ -119,9 +119,9 @@ private:
QQmlObjectData objectData(QObject *);
QQmlObjectProperty propertyData(QObject *, int);
QVariant valueContents(const QVariant &defaultValue) const;
- void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0);
- void resetBinding(int objectId, const QString &propertyName);
- void setMethodBody(int objectId, const QString &method, const QString &body);
+ bool setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1, int column = 0);
+ bool resetBinding(int objectId, const QString &propertyName);
+ bool setMethodBody(int objectId, const QString &method, const QString &body);
QList<QQmlEngine *> m_engines;
QQmlWatcher *m_watch;
diff --git a/src/qml/qml/qqmlwatcher.cpp b/src/qml/qml/qqmlwatcher.cpp
index 500185762f..4eaa3d2c2a 100644
--- a/src/qml/qml/qqmlwatcher.cpp
+++ b/src/qml/qml/qqmlwatcher.cpp
@@ -166,13 +166,14 @@ bool QQmlWatcher::addWatch(int id, quint32 objectId, const QString &expr)
return false;
}
-void QQmlWatcher::removeWatch(int id)
+bool QQmlWatcher::removeWatch(int id)
{
if (!m_proxies.contains(id))
- return;
+ return false;
QList<QPointer<QQmlWatchProxy> > proxies = m_proxies.take(id);
qDeleteAll(proxies);
+ return true;
}
void QQmlWatcher::addPropertyWatch(int id, QObject *object, quint32 debugId, const QMetaProperty &property)
diff --git a/src/qml/qml/qqmlwatcher_p.h b/src/qml/qml/qqmlwatcher_p.h
index 70dc9d468c..3ca2c83777 100644
--- a/src/qml/qml/qqmlwatcher_p.h
+++ b/src/qml/qml/qqmlwatcher_p.h
@@ -77,7 +77,7 @@ public:
bool addWatch(int id, quint32 objectId, const QByteArray &property);
bool addWatch(int id, quint32 objectId, const QString &expr);
- void removeWatch(int id);
+ bool removeWatch(int id);
Q_SIGNALS:
void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);