QQmlContext *context = qmlContext(object);
if (object && context) {
- if (object->property(propertyName.toLatin1()).isValid()) {
+ QString parentProperty = propertyName;
+ if (propertyName.indexOf(QLatin1Char('.')) != -1)
+ parentProperty = propertyName.left(propertyName.indexOf(QLatin1Char('.')));
+
+ if (object->property(parentProperty.toLatin1()).isValid()) {
QQmlProperty property(object, propertyName);
QQmlAbstractBinding *oldBinding = QQmlPropertyPrivate::binding(property);
if (oldBinding) {
// overwrite with default value
if (QQmlType *objType = QQmlMetaType::qmlType(object->metaObject())) {
if (QObject *emptyObject = objType->create()) {
- if (emptyObject->property(propertyName.toLatin1()).isValid()) {
+ if (emptyObject->property(parentProperty.toLatin1()).isValid()) {
QVariant defaultValue = QQmlProperty(emptyObject, propertyName).read();
if (defaultValue.isValid()) {
setBinding(objectId, propertyName, defaultValue, true);
}
}
}
- } else if (hasValidSignal(object, propertyName)) {
+ return true;
+ }
+
+ if (hasValidSignal(object, propertyName)) {
QQmlProperty property(object, propertyName, context);
QQmlPropertyPrivate::setSignalExpression(property, 0);
- } else {
- if (m_statesDelegate)
- m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
+ return true;
}
+
+ if (m_statesDelegate) {
+ m_statesDelegate->resetBindingForInvalidProperty(object, propertyName);
+ return true;
+ }
+
+ return false;
}
- return true;
+ // object or context null.
+ return false;
}
bool QQmlEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
void queryExpressionResultBC_data();
void setBindingForObject();
+ void resetBindingForObject();
void setMethodBody();
void queryObjectTree();
void setBindingInStates();
"id: root\n"
"width: 10; height: 20; scale: blueRect.scale;"
"Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }"
- "Text { color: blueRect.color; }"
+ "Text { font.bold: true; color: blueRect.color; }"
"MouseArea {"
"onEntered: { console.log('hello') }"
"}"
QCOMPARE(widthPropertyRef.binding, QString("height"));
//
- // reset
- //
- m_dbg->resetBindingForObject(rootObject.debugId, "width", &success);
- QVERIFY(success);
- QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
- QCOMPARE(m_dbg->valid(), true);
-
- rootObject = findRootObject();
- widthPropertyRef = findProperty(rootObject.properties, "width");
-
- // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work?
- QCOMPARE(widthPropertyRef.binding, QString());
-
- //
// set handler
//
rootObject = findRootObject();
QCOMPARE(onEnteredRef.value, QVariant("{console.log('hello, world') }"));
}
+void tst_QQmlEngineDebugService::resetBindingForObject()
+{
+ QmlDebugObjectReference rootObject = findRootObject();
+ QVERIFY(rootObject.debugId != -1);
+ QmlDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties, "width");
+
+ bool success = false;
+
+ m_dbg->setBindingForObject(rootObject.debugId, "width", "15", true,
+ QString(), -1, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
+
+ //
+ // reset
+ //
+ m_dbg->resetBindingForObject(rootObject.debugId, "width", &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
+
+ rootObject = findRootObject();
+ widthPropertyRef = findProperty(rootObject.properties, "width");
+
+ QCOMPARE(widthPropertyRef.value, QVariant(0));
+ QCOMPARE(widthPropertyRef.binding, QString());
+
+ //
+ // reset nested property
+ //
+ success = false;
+ m_dbg->resetBindingForObject(rootObject.debugId, "font.bold", &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+ QCOMPARE(m_dbg->valid(), true);
+
+ rootObject = findRootObject();
+ QmlDebugPropertyReference boldPropertyRef = findProperty(rootObject.properties, "font.bold");
+
+ QCOMPARE(boldPropertyRef.value.toBool(), false);
+ QCOMPARE(boldPropertyRef.binding, QString());
+}
+
void tst_QQmlEngineDebugService::setBindingInStates()
{
// Check if changing bindings of propertychanges works