diff options
author | Lasse Holmstedt <lasse.holmstedt@nokia.com> | 2010-07-09 09:37:48 (GMT) |
---|---|---|
committer | Lasse Holmstedt <lasse.holmstedt@nokia.com> | 2010-07-09 11:03:26 (GMT) |
commit | e55781212532e2abcdd1cef8548b146fb14f0713 (patch) | |
tree | de556bc61a3e9a9b4fc8adce468810933128b3b6 /src | |
parent | 74a248462ef36f7784fd0816ee08030412459930 (diff) | |
download | Qt-e55781212532e2abcdd1cef8548b146fb14f0713.zip Qt-e55781212532e2abcdd1cef8548b146fb14f0713.tar.gz Qt-e55781212532e2abcdd1cef8548b146fb14f0713.tar.bz2 |
Resetting bindings through debugger interface
Reviewed-by: Aaron Kennedy
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/debugger/qdeclarativedebug.cpp | 15 | ||||
-rw-r--r-- | src/declarative/debugger/qdeclarativedebug_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeenginedebug.cpp | 27 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeenginedebug_p.h | 1 |
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; |