Skip to content

Commit 07687af

Browse files
Merge pull request #4183 from arcadiogarcia/user/arcadiog/clearReferenceInfo
Clear ReferenceNode ParamNames before serializing each expression string to avoid collisions
2 parents 5dfc575 + fa6a3ed commit 07687af

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/CompositionExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ public static void StartAnimation(this CompositionObject compObject, string prop
176176
/// <param name="easing">The easing function to use when interpolating between frames.</param>
177177
public static void InsertExpressionKeyFrame(this KeyFrameAnimation keyframeAnimation, float normalizedProgressKey, ExpressionNode expressionNode, CompositionEasingFunction easing = null)
178178
{
179+
expressionNode.ClearReferenceInfo();
180+
179181
keyframeAnimation.InsertExpressionKeyFrame(normalizedProgressKey, expressionNode.ToExpressionString(), easing);
180182

181183
expressionNode.SetAllParameters(keyframeAnimation);
@@ -252,6 +254,7 @@ private static ExpressionAnimation CreateExpressionAnimationFromNode(Compositor
252254
// Only create a new animation if this node hasn't already generated one before, so we don't have to re-parse the expression string.
253255
if (expressionNode.ExpressionAnimation == null)
254256
{
257+
expressionNode.ClearReferenceInfo();
255258
expressionNode.ExpressionAnimation = compositor.CreateExpressionAnimation(expressionNode.ToExpressionString());
256259
}
257260

Microsoft.Toolkit.Uwp.UI.Animations/Expressions/ExpressionNodes/ExpressionNode.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,20 @@ internal string ToExpressionString()
260260
return ToExpressionStringInternal();
261261
}
262262

263+
/// <summary>
264+
/// Clears the reference information.
265+
/// </summary>
266+
/// <exception cref="System.Exception">Reference and paramName can't both be null</exception>
267+
internal void ClearReferenceInfo()
268+
{
269+
_objRefList = null;
270+
ParamName = null;
271+
foreach (var child in Children)
272+
{
273+
child.ClearReferenceInfo();
274+
}
275+
}
276+
263277
/// <summary>
264278
/// Ensures the reference information.
265279
/// </summary>

0 commit comments

Comments
 (0)