From af8e4f8439eadbfad604967ef0dca38911638a86 Mon Sep 17 00:00:00 2001 From: agnelovaz Date: Tue, 21 Jan 2020 02:31:13 +0000 Subject: [PATCH] [NUI] Fix reparenting of Child bug (#1314) 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 --- .../src/public/BaseComponents/ViewPublicMethods.cs | 6 +++++- src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs | 8 ++++++-- src/Tizen.NUI/src/public/Layouting/LayoutItem.cs | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs index 4d22a3d..5e86a2b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs @@ -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; diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs index 1623b54..52138ca 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutGroup.cs @@ -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. diff --git a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs index a4518fb..b57889b 100755 --- a/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs +++ b/src/Tizen.NUI/src/public/Layouting/LayoutItem.cs @@ -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; + /// /// [Draft] Condition event that is causing this Layout to transition. /// @@ -303,6 +305,21 @@ namespace Tizen.NUI } } + internal void SetReplaceFlag() + { + parentReplacement = true; + } + + internal bool IsReplaceFlag() + { + return parentReplacement; + } + + internal void ClearReplaceFlag() + { + parentReplacement = false; + } + /// /// Get the measured width (without any measurement flags).
/// This method should be used only during measurement and layout calculations.
-- 2.7.4