From 2ecb7eebdc950eb559b9203d70077301b8b5a3b1 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 26 Jul 2010 15:40:10 +0200 Subject: QDeclarativeEngineDebugServer: Fix crash when trying to update non-properties. QDeclarativePropertyPrivate::setBinding would delete the binding if it cannot set the property. Then the call to binding->update() would crash. So test for (property.isProperty()) before. Also this will display a warning in the application output if the property cannot be changed. Reviewed-by: Lasse Holmstedt --- src/declarative/qml/qdeclarativeenginedebug.cpp | 30 ++++++++++++------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 008d054..1837366 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -485,24 +485,22 @@ void QDeclarativeEngineDebugServer::setBinding(int objectId, if (object && context) { + QDeclarativeProperty property(object, propertyName, context); if (isLiteralValue) { - QDeclarativeProperty literalProperty(object, propertyName, context); - literalProperty.write(expression); + property.write(expression); + } else if (hasValidSignal(object, propertyName)) { + QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); + QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); + } else if (property.isProperty()) { + QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); + binding->setTarget(property); + binding->setNotifyOnValueChanged(true); + QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); + if (oldBinding) + oldBinding->destroy(); + binding->update(); } else { - if (hasValidSignal(object, propertyName)) { - QDeclarativeProperty property(object, propertyName); - QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString()); - QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression); - } else { - QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - QDeclarativeProperty property(object, propertyName, context); - binding->setTarget(property); - binding->setNotifyOnValueChanged(true); - QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding); - if (oldBinding) - oldBinding->destroy(); - binding->update(); - } + qWarning() << "QDeclarativeEngineDebugServer::setBinding: unable to set property" << propertyName << "on object" << object; } } } -- cgit v0.12