forked from qt-creator/qt-creator
QmlDesigner: Delete animations if target is deleted
Task-number: QDS-5221 Change-Id: I98d1a370bf73ef298d3f309d0129b85e2147de6a Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Thomas Hartmann
parent
df904decd0
commit
8770c8674d
@@ -338,6 +338,48 @@ static void removeStateOperationsForChildren(const QmlObjectNode &node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void removeAnimationsFromAnimation(const ModelNode &animation)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(animation.isValid(), return);
|
||||||
|
|
||||||
|
const QList<ModelNode> propertyAnimations = animation.subModelNodesOfType(
|
||||||
|
"QtQuick.PropertyAnimation");
|
||||||
|
|
||||||
|
for (const ModelNode &child : propertyAnimations) {
|
||||||
|
if (!child.hasBindingProperty("target")) {
|
||||||
|
ModelNode nonConst = animation;
|
||||||
|
nonConst.destroy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void removeAnimationsFromTransition(const ModelNode &transition, const QmlObjectNode &node)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(node.isValid(), return);
|
||||||
|
QTC_ASSERT(transition.isValid(), return);
|
||||||
|
|
||||||
|
const auto children = transition.directSubModelNodes();
|
||||||
|
for (const ModelNode ¶llel : children)
|
||||||
|
removeAnimationsFromAnimation(parallel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void removeDanglingAnimationsFromTransitions(const QmlObjectNode &node)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(node.isValid(), return);
|
||||||
|
|
||||||
|
auto root = node.view()->rootModelNode();
|
||||||
|
|
||||||
|
if (root.isValid() && root.hasProperty("transitions")) {
|
||||||
|
NodeAbstractProperty transitions = root.nodeAbstractProperty("transitions");
|
||||||
|
if (transitions.isValid()) {
|
||||||
|
const auto transitionNodes = transitions.directSubNodes();
|
||||||
|
for (const auto &transition : transitionNodes)
|
||||||
|
removeAnimationsFromTransition(transition, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void removeAliasExports(const QmlObjectNode &node)
|
static void removeAliasExports(const QmlObjectNode &node)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -416,6 +458,8 @@ void QmlObjectNode::destroy()
|
|||||||
removeStateOperationsForChildren(modelNode());
|
removeStateOperationsForChildren(modelNode());
|
||||||
deleteAllReferencesToNodeAndChildren(modelNode());
|
deleteAllReferencesToNodeAndChildren(modelNode());
|
||||||
|
|
||||||
|
removeDanglingAnimationsFromTransitions(modelNode());
|
||||||
|
|
||||||
QmlFlowViewNode root(view()->rootModelNode());
|
QmlFlowViewNode root(view()->rootModelNode());
|
||||||
|
|
||||||
modelNode().destroy();
|
modelNode().destroy();
|
||||||
|
Reference in New Issue
Block a user