fix crash on collecitonView when setting layouter padding (#2960)
authorSangHyeon Jade Lee <sh10233.lee@samsung.com>
Thu, 29 Apr 2021 12:29:33 +0000 (21:29 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 7 May 2021 05:58:58 +0000 (14:58 +0900)
currently create two collectionView can be aborted while
accessing padding of layouter style.

use "using" keyword as GetViewStyle simply Copy the original
ViewStyle and will be disposed by using keyword,
but it occurs crash as CopyFrom only new the parent and copy
all existing values.
remove using keyward on first step.

src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs

index 2fdbc35..671a648 100755 (executable)
@@ -285,13 +285,10 @@ namespace Tizen.NUI.Components
                 needInitalizeLayouter = true;
 
                 var styleName = "Tizen.NUI.Components." + (itemsLayouter is LinearLayouter? "LinearLayouter" : (itemsLayouter is GridLayouter ? "GridLayouter" : "ItemsLayouter"));
-                using (ViewStyle layouterStyle = ThemeManager.GetStyle(styleName))
+                ViewStyle layouterStyle = ThemeManager.GetStyle(styleName);
+                if (layouterStyle != null)
                 {
-                    if (layouterStyle != null)
-                    {
-                        if (layouterStyle.Padding != null)
-                            itemsLayouter.Padding = new Extents(layouterStyle.Padding);
-                    }
+                    itemsLayouter.Padding = new Extents(layouterStyle.Padding);
                 }
                 Init();
             }
@@ -753,11 +750,9 @@ namespace Tizen.NUI.Components
             if (itemsLayouter != null)
             {
                 string styleName = "Tizen.NUI.Compoenents." + (itemsLayouter is LinearLayouter? "LinearLayouter" : (itemsLayouter is GridLayouter ? "GridLayouter" : "ItemsLayouter"));
-                using (ViewStyle layouterStyle = ThemeManager.GetStyle(styleName))
-                {
-                    if (layouterStyle != null)
-                        itemsLayouter.Padding = new Extents(layouterStyle.Padding);
-                }
+                ViewStyle layouterStyle = ThemeManager.GetStyle(styleName);
+                if (layouterStyle != null)
+                    itemsLayouter.Padding = new Extents(layouterStyle.Padding);
             }
         }