summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorLasse Holmstedt <lasse.holmstedt@nokia.com>2010-07-09 09:37:48 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-07-15 07:08:57 (GMT)
commitd5e9a275ce6af16ef78f85463aa0bbaf11131490 (patch)
treee69019eff2227dafaccc1699c520f3d7b889fa4e /src/declarative
parent3d982368945fbbf5c3b5a1846c32292e3e9b6ab4 (diff)
downloadQt-d5e9a275ce6af16ef78f85463aa0bbaf11131490.zip
Qt-d5e9a275ce6af16ef78f85463aa0bbaf11131490.tar.gz
Qt-d5e9a275ce6af16ef78f85463aa0bbaf11131490.tar.bz2
Resetting bindings through debugger interface
Reviewed-by: Aaron Kennedy (cherry picked from commit e55781212532e2abcdd1cef8548b146fb14f0713)
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/debugger/qdeclarativedebug.cpp15
-rw-r--r--src/declarative/debugger/qdeclarativedebug_p.h1
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug.cpp27
-rw-r--r--src/declarative/qml/qdeclarativeenginedebug_p.h1
4 files changed, 44 insertions, 0 deletions
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativedebug.cpp
index 0c0cf2e..b950aef 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativedebug.cpp
@@ -579,6 +579,21 @@ bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QStri
}
}
+bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName)
+{
+ Q_D(QDeclarativeEngineDebug);
+
+ if (d->client->isConnected() && objectDebugId != -1) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName;
+ d->client->sendMessage(message);
+ return true;
+ } else {
+ return false;
+ }
+}
+
bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName,
const QString &methodBody)
{
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativedebug_p.h
index 9c38184..2e79c5d 100644
--- a/src/declarative/debugger/qdeclarativedebug_p.h
+++ b/src/declarative/debugger/qdeclarativedebug_p.h
@@ -96,6 +96,7 @@ public:
QObject *parent = 0);
bool setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression, bool isLiteralValue);
+ bool resetBindingForObject(int objectDebugId, const QString &propertyName);
bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody);
private:
diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp
index acd7ab6..001da46 100644
--- a/src/declarative/qml/qdeclarativeenginedebug.cpp
+++ b/src/declarative/qml/qdeclarativeenginedebug.cpp
@@ -461,6 +461,11 @@ void QDeclarativeEngineDebugServer::messageReceived(const QByteArray &message)
bool isLiteralValue;
ds >> objectId >> propertyName >> expr >> isLiteralValue;
setBinding(objectId, propertyName, expr, isLiteralValue);
+ } else if (type == "RESET_BINDING") {
+ int objectId;
+ QString propertyName;
+ ds >> objectId >> propertyName;
+ resetBinding(objectId, propertyName);
} else if (type == "SET_METHOD_BODY") {
int objectId;
QString methodName;
@@ -502,6 +507,28 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId,
}
}
+void QDeclarativeEngineDebugServer::resetBinding(int objectId, const QString &propertyName)
+{
+ QObject *object = objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+
+ if (object && context) {
+ if (object->property(propertyName.toLatin1()).isValid()) {
+ QDeclarativeProperty property(object, propertyName);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property);
+ if (oldBinding) {
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0);
+ if (oldBinding)
+ oldBinding->destroy();
+ } else {
+ if (property.isResettable()) {
+ property.reset();
+ }
+ }
+ }
+ }
+}
+
void QDeclarativeEngineDebugServer::setMethodBody(int objectId, const QString &method, const QString &body)
{
QObject *object = objectForId(objectId);
diff --git a/src/declarative/qml/qdeclarativeenginedebug_p.h b/src/declarative/qml/qdeclarativeenginedebug_p.h
index ce6df0d..ea35b40 100644
--- a/src/declarative/qml/qdeclarativeenginedebug_p.h
+++ b/src/declarative/qml/qdeclarativeenginedebug_p.h
@@ -108,6 +108,7 @@ private:
QDeclarativeObjectProperty propertyData(QObject *, int);
QVariant valueContents(const QVariant &defaultValue) const;
void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue);
+ void resetBinding(int objectId, const QString &propertyName);
void setMethodBody(int objectId, const QString &method, const QString &body);
static QList<QDeclarativeEngine *> m_engines;