Skip to content
Snippets Groups Projects
Commit 94356a07 authored by Marco Bubke's avatar Marco Bubke Committed by Kai Koehne
Browse files

Set a binding in states to zero if the target object is zero

If there is no target anymore you cannot create a new binding. There is
no need anyway so the binding is reset to zero.

Task-Number: BAUHAUS-642
Reviewed-by: kkoehne
parent fa640f66
No related branches found
No related tags found
No related merge requests found
......@@ -60,12 +60,16 @@ QDeclarativeStateOperation::ActionList QmlPropertyChangesObject::actions()
action.fromValue = action.property.read();
if (m_expressionHash.contains(action.specifiedProperty)) {
if(m_expressionHash[action.specifiedProperty].second.isNull()) {
QDeclarativeBinding *binding = new QDeclarativeBinding(m_expressionHash[action.specifiedProperty].first, targetObject(), QDeclarativeEngine::contextForObject(targetObject()), this);
binding->setTarget(action.property);
binding->setNotifyOnValueChanged(true);
action.toBinding = binding;
action.toValue = binding->evaluate();
m_expressionHash.insert(action.specifiedProperty, ExpressionPair(m_expressionHash[action.specifiedProperty].first, binding));
if (targetObject()) {
QDeclarativeBinding *binding = new QDeclarativeBinding(m_expressionHash[action.specifiedProperty].first, targetObject(), QDeclarativeEngine::contextForObject(targetObject()), this);
binding->setTarget(action.property);
binding->setNotifyOnValueChanged(true);
action.toBinding = binding;
action.toValue = binding->evaluate();
m_expressionHash.insert(action.specifiedProperty, ExpressionPair(m_expressionHash[action.specifiedProperty].first, binding));
} else {
action.toBinding = 0;
}
} else {
action.toBinding = m_expressionHash[action.specifiedProperty].second.data();
action.toValue = m_expressionHash[action.specifiedProperty].second->evaluate();
......@@ -92,9 +96,10 @@ void QmlPropertyChangesObject::setTargetObject(QObject *object)
if (isActive()) {
QDeclarativePropertyPrivate::setBinding(qmlAction.property, 0, QDeclarativePropertyPrivate::DontRemoveBinding| QDeclarativePropertyPrivate::BypassInterceptor);
qmlAction.property.write(qmlAction.fromValue);
m_expressionHash[qmlAction.specifiedProperty].second.data()->destroy();
}
m_expressionHash[qmlAction.specifiedProperty].second.data()->destroy();
qmlAction.toBinding = 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment