[NUI] Fix Svace issues
authorzhouleonlei <zhouleon.lei@samsung.com>
Mon, 10 May 2021 12:33:53 +0000 (20:33 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 21 May 2021 07:37:43 +0000 (16:37 +0900)
21 files changed:
src/Tizen.NUI.Components/Controls/Loading.cs
src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.Internal.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/GridLayouter.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Layouter/LinearLayouter.cs
src/Tizen.NUI/src/internal/EXaml/Action/AddEventAction.cs
src/Tizen.NUI/src/internal/EXaml/Action/AddToResourceDictionary.cs
src/Tizen.NUI/src/internal/EXaml/Action/CallAddMethodAction.cs
src/Tizen.NUI/src/internal/EXaml/Action/SetBindalbePropertyAction.cs
src/Tizen.NUI/src/internal/EXaml/Action/SetBindingAction.cs
src/Tizen.NUI/src/internal/EXaml/Action/SetDynamicResourceAction.cs
src/Tizen.NUI/src/internal/EXaml/Action/SetPropertyAction.cs
src/Tizen.NUI/src/internal/EXaml/Block/GatherTypesBlock.cs
src/Tizen.NUI/src/internal/EXaml/Operation/AddToResourceDictionary.cs
src/Tizen.NUI/src/internal/EXaml/Operation/GatherBindableProperties.cs
src/Tizen.NUI/src/internal/EXaml/Operation/GatherConvertedValue.cs
src/Tizen.NUI/src/internal/EXaml/Operation/SetDynamicResource.cs
src/Tizen.NUI/src/internal/Layouting/LayoutController.cs
src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs
src/Tizen.NUI/src/public/Layouting/FlexLayout.cs

index f982359..1d01a18 100755 (executable)
@@ -134,7 +134,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 6 </since_tizen>
         public string[] ImageArray
         {
-            get => (GetValue(ImageListProperty) as List<string>).ToArray();
+            get => (GetValue(ImageListProperty) as List<string>)?.ToArray() ?? null;
             set => SetValue(ImageListProperty, value == null ? new List<string>() : new List<string>((string[])value));
         }
 
index e2d7ef6..9ea3075 100755 (executable)
@@ -833,10 +833,14 @@ namespace Tizen.NUI.Components
                         groupHeader.isGroupFooter = false;
                         ContentContainer.Add(groupHeader);
                     }
-                    groupHeader.ParentItemsView = this;
-                    groupHeader.Index = index;
-                    groupHeader.ParentGroup = context;
-                    groupHeader.BindingContext = context;
+
+                    if (groupHeader != null)
+                    {
+                        groupHeader.ParentItemsView = this;
+                        groupHeader.Index = index;
+                        groupHeader.ParentGroup = context;
+                        groupHeader.BindingContext = context;
+                    }
                     //group selection?
                     item = groupHeader;
                 }
@@ -854,11 +858,14 @@ namespace Tizen.NUI.Components
                         groupFooter.isGroupFooter = true;
                         ContentContainer.Add(groupFooter);
                     }
-                    groupFooter.ParentItemsView = this;
-                    groupFooter.Index = index;
-                    groupFooter.ParentGroup = context;
-                    groupFooter.BindingContext = context;
 
+                    if (groupFooter != null)
+                    {
+                        groupFooter.ParentItemsView = this;
+                        groupFooter.Index = index;
+                        groupFooter.ParentGroup = context;
+                        groupFooter.BindingContext = context;
+                    }
                     //group selection?
                     item = groupFooter;
                 }
index d442144..23a1b5f 100755 (executable)
@@ -132,9 +132,8 @@ namespace Tizen.NUI.Components
 
                         if (IsSelectable)
                         {
-                            if (ParentItemsView as CollectionView)
+                            if (ParentItemsView is CollectionView colView)
                             {
-                                CollectionView colView = ParentItemsView as CollectionView;
                                 switch (colView.SelectionMode)
                                 {
                                     case ItemSelectionMode.Single:
index f728cd2..ce8d840 100755 (executable)
@@ -215,9 +215,8 @@ namespace Tizen.NUI.Components
                     if (IsSelectable)
                     {
                         // Extension : Extension?.SetTouchInfo(touch);
-                        if (ParentItemsView as CollectionView)
+                        if (ParentItemsView is CollectionView colView)
                         {
-                            CollectionView colView = ParentItemsView as CollectionView;
                             switch (colView.SelectionMode)
                             {
                                 case ItemSelectionMode.Single:
index 9fd9e49..7821d7a 100755 (executable)
@@ -1230,7 +1230,7 @@ namespace Tizen.NUI.Components
             if (targetSibling > -1 && targetSibling < Container.Children.Count)
             {
                 RecyclerViewItem candidate = Container.Children[targetSibling] as RecyclerViewItem;
-                if (candidate.Index >= 0 && candidate.Index < colView.InternalItemSource.Count)
+                if (candidate != null && candidate.Index >= 0 && candidate.Index < colView.InternalItemSource.Count)
                 {
                     nextFocusedView = candidate;
                 }
index 6a15035..1c5bd10 100755 (executable)
@@ -1325,7 +1325,7 @@ namespace Tizen.NUI.Components
             if (targetSibling > -1 && targetSibling < Container.Children.Count)
             {
                 RecyclerViewItem candidate = Container.Children[targetSibling] as RecyclerViewItem;
-                if (candidate.Index >= 0 && candidate.Index < colView.InternalItemSource.Count)
+                if (candidate != null && candidate.Index >= 0 && candidate.Index < colView.InternalItemSource.Count)
                 {
                     nextFocusedView = candidate;
                 }
index 60fb053..abdbc22 100755 (executable)
@@ -64,10 +64,10 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 3 && (childOp.ValueList[0] is Instance instance) && (childOp.ValueList[1] is Instance element))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
-                int elementIndex = (childOp.ValueList[1] as Instance).Index;
+                int instanceIndex = instance.Index;
+                int elementIndex = element.Index;
                 int propertyIndex = (int)childOp.ValueList[2];
                 int value = (int)childOp.ValueList[3];
                 globalDataList.Operations.Add(new AddEvent(globalDataList, instanceIndex, elementIndex, propertyIndex, value));
index 76874e0..2667d03 100755 (executable)
@@ -64,10 +64,9 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance) && (childOp.ValueList[1] is string key))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
-                string key = childOp.ValueList[1] as string;
+                int instanceIndex = instance.Index;
                 var value = childOp.ValueList[2];
                 globalDataList.Operations.Add(new AddToResourceDictionary(globalDataList, instanceIndex, key, value));
             }
index 701c12f..fc69b14 100755 (executable)
@@ -64,10 +64,10 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance) && (childOp.ValueList[1] is Instance child))
             {
-                int parentIndex = (childOp.ValueList[0] as Instance).Index;
-                int childIndex = (childOp.ValueList[1] as Instance).Index;
+                int parentIndex = instance.Index;
+                int childIndex = child.Index;
                 int methodIndex = (int)childOp.ValueList[2];
 
                 globalDataList.Operations.Add(new CallAddMethod(globalDataList, parentIndex, childIndex, methodIndex));
index c48cba5..773570a 100755 (executable)
@@ -64,9 +64,9 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
+                int instanceIndex = instance.Index;
                 int bindalbePropertyIndex = (int)childOp.ValueList[1];
                 var value = childOp.ValueList[2];
                 globalDataList.Operations.Add(new SetBindalbeProperty(globalDataList, instanceIndex, bindalbePropertyIndex, value));
index 5036aaf..08d42ca 100755 (executable)
@@ -64,11 +64,11 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance) && (childOp.ValueList[2] is Instance value))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
+                int instanceIndex = instance.Index;
                 var propertyIndex = (int)childOp.ValueList[1];
-                int valueIndex = (childOp.ValueList[2] as Instance).Index;
+                int valueIndex = value.Index;
 
                 globalDataList.Operations.Add(new SetBinding(globalDataList, instanceIndex, propertyIndex, valueIndex));
             }
index 6cffcc5..c17e805 100755 (executable)
@@ -61,12 +61,10 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance) && (childOp.ValueList[2] is string key))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
+                int instanceIndex = instance.Index;
                 int propertyIndex = (int)childOp.ValueList[1];
-                string key = childOp.ValueList[2] as string;
-
                 globalDataList.Operations.Add(new SetDynamicResource(globalDataList, instanceIndex, propertyIndex, key));
             }
         }
index 2dc2c06..837741b 100755 (executable)
@@ -64,9 +64,9 @@ namespace Tizen.NUI.EXaml
 
         public void OnActive()
         {
-            if (null != childOp)
+            if (null != childOp && childOp.ValueList.Count > 2 && (childOp.ValueList[0] is Instance instance))
             {
-                int instanceIndex = (childOp.ValueList[0] as Instance).Index;
+                int instanceIndex = instance.Index;
                 int propertyIndex = (int)childOp.ValueList[1];
                 var value = childOp.ValueList[2];
                 globalDataList.Operations.Add(new SetProperty(globalDataList, instanceIndex, propertyIndex, value));
index 2f4a280..0fe0255 100755 (executable)
@@ -75,11 +75,13 @@ namespace Tizen.NUI.EXaml
             {
                 List<int> genericTypeIndexs = new List<int>();
                 var genericTypeIndexList = valueList[1] as List<object>;
-                foreach (var index in genericTypeIndexList)
+                if (genericTypeIndexList != null)
                 {
-                    genericTypeIndexs.Add((int)index);
+                    foreach (var index in genericTypeIndexList)
+                    {
+                        genericTypeIndexs.Add((int)index);
+                    }
                 }
-
                 return new GatherType(globalDataList, assemblyIndex, typeName, genericTypeIndexs);
             }
             else
index e2187ab..5262820 100755 (executable)
@@ -41,7 +41,7 @@ namespace Tizen.NUI.EXaml
             var instance = globalDataList.GatheredInstances[instanceIndex] as ResourceDictionary;
             var realValue = (value is Instance) ? globalDataList.GatheredInstances[(value as Instance).Index] : value;
 
-            instance.Add(key, realValue);
+            instance?.Add(key, realValue);
         }
 
         private int instanceIndex;
index f077d7e..720f085 100755 (executable)
@@ -44,7 +44,10 @@ namespace Tizen.NUI.EXaml
                 field = type.GetField(fi => fi.Name == propertyName && fi.IsStatic && !fi.IsPublic);
             }
 
-            globalDataList.GatheredBindableProperties.Add(field.GetValue(null) as BindableProperty);
+            if (null != field && field.GetValue(null) is BindableProperty value)
+            {
+                globalDataList.GatheredBindableProperties.Add(value);
+            }
         }
 
         private int typeIndex;
index 48805d8..484f65d 100755 (executable)
@@ -38,7 +38,7 @@ namespace Tizen.NUI.EXaml
         public void Do()
         {
             var converter = globalDataList.GatheredInstances[converterIndex] as TypeConverter;
-            globalDataList.GatheredInstances.Add(converter.ConvertFromInvariantString(value));
+            globalDataList.GatheredInstances.Add(converter?.ConvertFromInvariantString(value));
         }
 
         private int converterIndex;
index b650fc0..00419b7 100755 (executable)
@@ -41,7 +41,7 @@ namespace Tizen.NUI.EXaml
             var instance = globalDataList.GatheredInstances[instanceIndex] as BindableObject;
             var property = globalDataList.GatheredBindableProperties[propertyIndex];
 
-            instance.SetDynamicResource(property, key);
+            instance?.SetDynamicResource(property, key);
         }
 
         private int instanceIndex;
index ef710cf..e9567a2 100755 (executable)
@@ -543,6 +543,10 @@ namespace Tizen.NUI
             SetupAnimationForPosition(layoutPositionData, positionTransitionComponents);
 
             SetupAnimationForSize(layoutPositionData, sizeTransitionComponents);
+
+            // Dispose components
+            positionTransitionComponents.Dispose();
+            sizeTransitionComponents.Dispose();
         }
 
     } // class LayoutController
index 3edc0d6..fec83f8 100755 (executable)
@@ -568,7 +568,7 @@ namespace Tizen.NUI.BaseComponents
         {
             var newStyle = value.Clone() as TOut;
 
-            newStyle.CopyFrom(other);
+            newStyle?.CopyFrom(other);
 
             return newStyle;
         }
index dc3da47..1bf8b30 100755 (executable)
@@ -811,7 +811,7 @@ namespace Tizen.NUI
                 {
                     // Get the frame for the child, start, top, end, bottom.
                     Vector4 frame = new Vector4(Interop.FlexLayout.GetNodeFrame(swigCPtr, childIndex), true);
-                    childLayout.Layout(new LayoutLength(frame.X), new LayoutLength(frame.Y), new LayoutLength(frame.Z), new LayoutLength(frame.W));
+                    childLayout?.Layout(new LayoutLength(frame.X), new LayoutLength(frame.Y), new LayoutLength(frame.Z), new LayoutLength(frame.W));
                     frame.Dispose();
                 }
             }