Add dependency to correct grand parent for linear gradients. The Text PR changed how we look-up a parent in the hierarchy to depend on for LinearGradient transforms. It introduced an issue where while we'd reference the right parent we wouldn't necessarily add the dependency to the correct one. We were using the current iterating node as the item to add the dependency to, which could be null if we didn't find one. In this case we still want to depend on the artboard. Diffs= 686e5125b Add dependency to correct grand parent for linear gradients. (#4753)
diff --git a/.rive_head b/.rive_head index 7c41e62..6dce88f 100644 --- a/.rive_head +++ b/.rive_head
@@ -1 +1 @@ -e737ee4278d071c8b502f2eb36b5c88caa7b1a0c +686e5125bd4c4e621cf51c282a0fa383f4006c2f
diff --git a/src/shapes/paint/linear_gradient.cpp b/src/shapes/paint/linear_gradient.cpp index 2acbe7d..6aec3f4 100644 --- a/src/shapes/paint/linear_gradient.cpp +++ b/src/shapes/paint/linear_gradient.cpp
@@ -32,26 +32,30 @@ auto p = parent(); if (p != nullptr && p->parent() != nullptr) { - auto parentsParent = p->parent(); + ContainerComponent* grandParent = p->parent(); // Parent's parent must be a shape paint container. - assert(ShapePaintContainer::from(parentsParent) != nullptr); + assert(ShapePaintContainer::from(grandParent) != nullptr); // We need to find the container that owns our world space transform. // This is the first node up the chain (or none, meaning we are in world // space). m_ShapePaintContainer = nullptr; - while (parentsParent != nullptr) + for (ContainerComponent* container = grandParent; container != nullptr; + container = container->parent()) { - if (parentsParent->is<Node>()) + if (container->is<Node>()) { - m_ShapePaintContainer = parentsParent->as<Node>(); + m_ShapePaintContainer = container->as<Node>(); break; } - parentsParent = parentsParent->parent(); } - if (parentsParent != nullptr) + if (m_ShapePaintContainer != nullptr) { - parentsParent->addDependent(this); + m_ShapePaintContainer->addDependent(this); + } + else + { + grandParent->addDependent(this); } } }