[NUI] Fix reparenting of Child bug (#1314) (#1333)
authorneostom432 <31119276+neostom432@users.noreply.github.com>
Tue, 21 Jan 2020 03:10:34 +0000 (12:10 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 21 Jan 2020 03:10:34 +0000 (12:10 +0900)
If a child is added to a different layout the transition finished
animation can cause it to be removed from the new parent.

Cause : The removal animation is added to the stack, the add animation is added to
the stack.  Animations are run.  When animations finish the itemRemovalQueue is run, this
removes the child as the removal code added it to the itemRemovalQueue.

Fix : In the case of replacement, set a flag on the child so the removal code can excluded it
from the itemRemovalQueue.

Change-Id: Ib7da9e446c990258c8415e584bbb624dae4d6fa5

Co-authored-by: agnelovaz <agnelo.vaz@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs
src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs
src/Tizen.NUI/src/public/Layouting/LayoutItem.cs

index 4d22a3d..5e86a2b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -128,6 +128,10 @@ namespace Tizen.NUI.BaseComponents
                 // If child already has a parent then re-parent child
                 if (oldParent != null)
                 {
+                    if (child.Layout !=null)
+                    {
+                        child.Layout.SetReplaceFlag();
+                    }
                     oldParent.Remove(child);
                 }
                 child.InternalParent = this;
index 1623b54..52138ca 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -88,7 +88,11 @@ namespace Tizen.NUI
             {
                 if( childLayout == layoutItem )
                 {
-                    Window.Instance.LayoutController.AddToRemovalStack(childLayout);
+                    if (! childLayout.IsReplaceFlag())
+                    {
+                        Window.Instance.LayoutController.AddToRemovalStack(childLayout);
+                    }
+                    childLayout.ClearReplaceFlag();
                     LayoutChildren.Remove(childLayout);
                     childLayout.ConditionForAnimation = childLayout.ConditionForAnimation | TransitionCondition.Remove;
                     // Add LayoutItem to the transition stack so can animate it out.
index a4518fb..b57889b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,6 +51,8 @@ namespace Tizen.NUI
         private Extents _padding;
         private Extents _margin;
 
+        private bool parentReplacement = false;
+
         /// <summary>
         /// [Draft] Condition event that is causing this Layout to transition.
         /// </summary>
@@ -303,6 +305,21 @@ namespace Tizen.NUI
             }
         }
 
+        internal void SetReplaceFlag()
+        {
+            parentReplacement = true;
+        }
+
+        internal bool IsReplaceFlag()
+        {
+            return parentReplacement;
+        }
+
+        internal void ClearReplaceFlag()
+        {
+            parentReplacement = false;
+        }
+
         /// <summary>
         /// Get the measured width (without any measurement flags).<br />
         /// This method should be used only during measurement and layout calculations.<br />