Commit 9d34246a authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne
Browse files

Resetting the binding for a property before destroying it.

Fixing a crash for resetting a binding in a state

Task-Number: BAUHAUS-624
Reviewed-by: kkoehne
parent 83954cda
......@@ -406,14 +406,18 @@ void QmlPropertyChangesObject::setExpression(const QString &name, const QString
m_qmlActionList.append(createQDeclarativeAction(name));
}
QDeclarativeContext *context = QDeclarativeEngine::contextForObject(targetObject());
QDeclarativeBinding *binding = 0;
QDeclarativeProperty metaProperty(targetObject(), name, context);
QDeclarativeAction &qmlAction = qmlActionForProperty(name);
if (m_expressionHash.contains(name) && m_expressionHash[name].second) {
m_expressionHash[name].second->destroy();
if (QDeclarativePropertyPrivate::binding(metaProperty) == m_expressionHash[name].second.data())
QDeclarativePropertyPrivate::setBinding(metaProperty, 0, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
m_expressionHash.take(name).second->destroy();
}
QDeclarativeContext *context = QDeclarativeEngine::contextForObject(targetObject());
QDeclarativeBinding *binding = 0;
QDeclarativeProperty metaProperty(targetObject(), name, context);
if (metaProperty.isValid() && metaProperty.isProperty()) {
binding = new QDeclarativeBinding(expression, targetObject(), context, this);
binding->setTarget(metaProperty);
......@@ -486,8 +490,12 @@ void QmlPropertyChangesObject::resetProperty(const QString &name)
}
if (m_expressionHash.contains(name)) {
if (m_expressionHash[name].second)
if (m_expressionHash[name].second) {
QDeclarativeProperty metaProperty(targetObject(), name, QDeclarativeEngine::contextForObject(targetObject()));
if (metaProperty.isValid() && QDeclarativePropertyPrivate::binding(metaProperty) == m_expressionHash[name].second.data())
QDeclarativePropertyPrivate::setBinding(metaProperty, 0, QDeclarativePropertyPrivate::BypassInterceptor | QDeclarativePropertyPrivate::DontRemoveBinding);
m_expressionHash[name].second.data()->destroy();
}
m_expressionHash.remove(name);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment