fix nullable member access code to prevent future crash.
authorEverLEEst(SangHyeon Lee) <sh10233.lee@samsung.com>
Thu, 13 May 2021 07:39:28 +0000 (16:39 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Thu, 13 May 2021 08:34:56 +0000 (17:34 +0900)
nullable members need to be check it is null or not,
and carefully null set after disposing.

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

index f5557df..125ef00 100755 (executable)
@@ -212,18 +212,16 @@ namespace Tizen.NUI.Components
                     {
                         prevNotifyCollectionChanged.CollectionChanged -= CollectionChanged;
                     }
-                    itemsLayouter.Clear();
+                    itemsLayouter?.Clear();
                     if (selectedItem != null) selectedItem = null;
-                    if (selectedItems != null)
-                    {
-                        selectedItems.Clear();
-                    }
+                    selectedItems?.Clear();
                 }
 
                 itemsSource = value;
                 if (value == null)
                 {
-                    if (InternalItemSource != null) InternalItemSource.Dispose();
+                    InternalItemSource?.Dispose();
+                    InternalItemSource = null;
                     //layouter.Clear()
                     return;
                 }
@@ -232,7 +230,7 @@ namespace Tizen.NUI.Components
                     newNotifyCollectionChanged.CollectionChanged += CollectionChanged;
                 }
 
-                if (InternalItemSource != null) InternalItemSource.Dispose();
+                InternalItemSource?.Dispose();
                 InternalItemSource = ItemsSourceFactory.Create(this);
 
                 if (itemsLayouter == null) return;