[NUI] Fix some SVACE issues.
authorhuayong.xu <huayong.xu@samsung.com>
Wed, 2 Aug 2023 02:27:38 +0000 (10:27 +0800)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 9 Aug 2023 07:58:31 +0000 (16:58 +0900)
13 files changed:
src/Tizen.NUI.Components/Controls/Control.cs
src/Tizen.NUI.Components/Controls/Picker.cs
src/Tizen.NUI.Components/Controls/RecyclerView/Item/RecyclerViewItem.cs
src/Tizen.NUI.Components/Controls/ScrollableBase.cs
src/Tizen.NUI/src/internal/Common/EnumHelper.cs
src/Tizen.NUI/src/internal/Xaml/CreateValuesVisitor.cs
src/Tizen.NUI/src/internal/XamlBinding/BindingExpression.cs
src/Tizen.NUI/src/public/BaseComponents/DirectRenderingGLView.cs
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/Rendering/VertexBuffer.cs
src/Tizen.NUI/src/public/XamlBinding/BindablePropertyConverter.cs

index 009f9b6373e0ed2aab401b8807de137e1baa073e..3145db3dc3f9758ff06f8f37187831c648a1ae4f 100755 (executable)
@@ -153,10 +153,6 @@ namespace Tizen.NUI.Components
                     {
                         Log.Error("NUI", $"[ERROR] Fail to initialize Feedback: {e}");
                     }
-                    catch (NullReferenceException e)
-                    {
-                        Log.Error("NUI", $"[ERROR] Null reference error in Feedback: {e}");
-                    }
                 }
                 else
                 {
index 5d339694003b9fc5200a12bc7eb9e18beac79fa5..2d53aa02542c923e742737a5311f5ac8f2adb452 100755 (executable)
@@ -850,14 +850,14 @@ namespace Tizen.NUI.Components
                     startScrollOffset = (int)pickerStyle.StartScrollOffset.Height;
                 }
 
-                if (pickerStyle.ItemTextLabel?.Size != null)
+                if (pickerStyle.ItemTextLabel?.Size is var itemSize && itemSize != null)
                 {
-                    itemHeight = (int)pickerStyle.ItemTextLabel.Size.Height;
+                    itemHeight = (int)itemSize.Height;
                 }
 
-                if (pickerStyle.Size != null)
+                if (pickerStyle.Size is var pSize && pSize != null)
                 {
-                    Size = new Size(-1, pickerStyle.Size.Height);
+                    Size = new Size(-1, pSize.Height);
                 }
             }
 
index 43f080eab9617a10e584e129b2018fd9688ea472..3f387cae3d9d352ee79a2135a1abe8abf6533c6a 100755 (executable)
@@ -68,7 +68,7 @@ namespace Tizen.NUI.Components
                         else if (collectionView.SelectionMode is ItemSelectionMode.Multiple)
                         {
                             var selectedList = collectionView.SelectedItems;
-                            if (selectedList != null)
+                            if (selectedList != null && context != null)
                             {
                                 bool contains = selectedList.Contains(context);
                                 if (newSelected && !contains)
index ae694727d8c8fc2922e426d80b9160b29a7377dd..22b2fb50d23ca726568d6a480e849840108b40ba 100755 (executable)
@@ -1121,7 +1121,7 @@ namespace Tizen.NUI.Components
         /// <since_tizen> 8 </since_tizen>
         public void ScrollToIndex(int index)
         {
-            if (ContentContainer.ChildCount - 1 < index || index < 0)
+            if ((int)ContentContainer.ChildCount - 1 < index || index < 0)
             {
                 return;
             }
index bfef6f3ff5192225941284c79737a38f3668cf9d..2e5d4d3fd37587f3de17d124d86ed7241f30748d 100755 (executable)
@@ -59,7 +59,8 @@ namespace Tizen.NUI
             {
                 if (description == field.Name)
                 {
-                    return (T)field.GetValue(null);
+                    var fvalue = field.GetValue(null);
+                    return fvalue != null ? (T)fvalue : default(T);
                 }
 
                 var attributes = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), true);
@@ -67,12 +68,14 @@ namespace Tizen.NUI
                 {
                     if (description == attributes.First().Description)
                     {
-                        return (T)field.GetValue(null);
+                        var fvalue = field.GetValue(null);
+                        return fvalue != null ? (T)fvalue : default(T);
                     }
                 }
             }
 
-            return (T)type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault().GetValue(null);
+            var value = type.GetFields(BindingFlags.Public | BindingFlags.Static).FirstOrDefault().GetValue(null);
+            return value != null ? (T)value : default(T);
             //throw new ArgumentException($"{description} can't be found.", "Description");
         }
 
index 97462a726ca98ff4e1f48406df4ad4498fe0386f..266e0b4603e72c7408bb4d749c9d94a4a6179fe5 100755 (executable)
@@ -203,7 +203,7 @@ namespace Tizen.NUI.Xaml
                 Values[node] = value;
             }
 
-            if (value is BindableObject)
+            if (value != null && value is BindableObject)
                 NameScope.SetNameScope(value as BindableObject, node.Namescope);
         }
 
index 78d342607e57f04844e4f7ca81e95ca360a70e74..53e0a919fc0a47ece5b92d8162d4dd536e81fe1b 100755 (executable)
@@ -99,19 +99,19 @@ namespace Tizen.NUI.Binding
             object sourceObject;
             if (_weakSource != null && _weakSource.TryGetTarget(out sourceObject))
             {
-                if (_parts.Count > 1)
+                for (var i = 0; i < _parts.Count; i++)
                 {
-                    for (var i = 0; i < _parts.Count - 1; i++)
-                    {
-                        BindingExpressionPart part = _parts[i];
+                    if (i + 1 == _parts.Count) //do not handle the last.
+                        break;
 
-                        if (!part.IsSelf)
-                        {
-                            part.TryGetValue(sourceObject, out sourceObject);
-                        }
+                    BindingExpressionPart part = _parts[i];
 
-                        part.Unsubscribe();
+                    if (!part.IsSelf)
+                    {
+                        part.TryGetValue(sourceObject, out sourceObject);
                     }
+
+                    part.Unsubscribe();
                 }
             }
 
index d98bb173beefa7517e1d76ab2c47661fdf99062b..b2bf0d90560d6b72391c355c7015c1af2dfc832b 100644 (file)
@@ -178,13 +178,14 @@ namespace Tizen.NUI.BaseComponents
         /// You can get the bind IDs in RenderCallbackInput in the glRenderFrame callback.
         /// </summary>
         /// <param name="textures">List of Textures</param>
+        /// <exception cref="OverflowException"> Thrown when length of textures list is overflow. </exception>
         public void BindTextureResources(List<Texture> textures)
         {
             unsafe
             {
-                if (textures != null && textures.Count > 0)
+                if (textures != null && sizeof(IntPtr) * textures.Count > 0)
                 {
-                    IntPtr unmanagedPointer = Marshal.AllocHGlobal(sizeof(IntPtr) * textures.Count);
+                    IntPtr unmanagedPointer = Marshal.AllocHGlobal(checked(sizeof(IntPtr) * textures.Count));
                     IntPtr[] texturesArray = new IntPtr[textures.Count];
                     for (int i = 0; i < textures.Count; i++)
                     {
index 0220e8991aab39ef5e66be6ae904cda13791bc7f..9c6e7a997465a25fd69877fcb603cdb089649688 100755 (executable)
@@ -2858,12 +2858,14 @@ namespace Tizen.NUI.BaseComponents
 
                 if (widthMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
                 {
-                    totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), maxSize.Width);
+                    float width = naturalSize != null ? naturalSize.Width : 0;
+                    totalWidth = Math.Min(Math.Max(width, minSize.Width), maxSize.Width);
                 }
 
                 if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
                 {
-                    totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), maxSize.Height);
+                    float height = naturalSize != null ? naturalSize.Height : 0;
+                    totalHeight = Math.Min(Math.Max(height, minSize.Height), maxSize.Height);
                 }
 
                 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
index f97b826cd482ffc7f70d36521508c04411fb904a..d23925630bc9a64d566ed88c973d6e55fde989d1 100755 (executable)
@@ -2863,12 +2863,14 @@ namespace Tizen.NUI.BaseComponents
 
                 if (widthMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
                 {
-                    totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), maxSize.Width);
+                    float width = naturalSize != null ? naturalSize.Width : 0;
+                    totalWidth = Math.Min(Math.Max(width, minSize.Width), maxSize.Width);
                 }
 
                 if (heightMeasureSpec.Mode != MeasureSpecification.ModeType.Exactly)
                 {
-                    totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), maxSize.Height);
+                    float height = naturalSize != null ? naturalSize.Height : 0;
+                    totalHeight = Math.Min(Math.Max(height, minSize.Height), maxSize.Height);
                 }
 
                 widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
index 51e5427d8fc25d1f92b9d4aa14ba33c99a69db3d..f3b532f8c11de30695afda831d2d2ade6cb615af 100755 (executable)
@@ -58,13 +58,16 @@ namespace Tizen.NUI.BaseComponents
                     if (heightMeasureSpec.Mode == MeasureSpecification.ModeType.Exactly)
                     {
                         // GetWidthForHeight is not implemented.
-                        totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
+                        float width = naturalSize != null ? naturalSize.Width : 0;
+                        totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
                     }
                     else
                     {
-                        totalWidth = Math.Min(Math.Max(naturalSize.Width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
-                        totalHeight = Math.Min(Math.Max(naturalSize.Height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
+                        float width = naturalSize != null ? naturalSize.Width : 0;
+                        float height = naturalSize != null ? naturalSize.Height : 0;
+                        totalWidth = Math.Min(Math.Max(width, minSize.Width), (maxSize.Width < 0 ? Int32.MaxValue : maxSize.Width));
+                        totalHeight = Math.Min(Math.Max(height, minSize.Height), (maxSize.Height < 0 ? Int32.MaxValue : maxSize.Height));
 
                         heightMeasureSpec = new MeasureSpecification(new LayoutLength(totalHeight), MeasureSpecification.ModeType.Exactly);
                         widthMeasureSpec = new MeasureSpecification(new LayoutLength(totalWidth), MeasureSpecification.ModeType.Exactly);
index 71a0a23bb1073489c18eed4c13ecc84288c1342b..8c4fd0dd165319d87b04726fea5f1ab2c2d1ea78 100755 (executable)
@@ -50,6 +50,7 @@ namespace Tizen.NUI
         /// </summary>
         /// <param name="vertices">The vertex data that will be copied to the buffer.</param>
         /// <exception cref="ArgumentNullException"> Thrown when vertices is null or length of the vertices is 0. </exception>
+        /// <exception cref="OverflowException"> Thrown when length of the vertices is overflow. </exception>
         /// <since_tizen> 8 </since_tizen>
 
         public void SetData<VertexType>(VertexType[] vertices) where VertexType : struct
@@ -60,7 +61,7 @@ namespace Tizen.NUI
             }
 
             int structSize = Marshal.SizeOf<VertexType>();
-            global::System.IntPtr buffer = Marshal.AllocHGlobal(structSize * vertices.Length);
+            global::System.IntPtr buffer = Marshal.AllocHGlobal(checked(structSize * vertices.Length));
 
             for (int i = 0; i < vertices.Length; i++)
             {
index 963cccc908e9c01af3163b941c5a177dedd5762a..3e349f972989ab351f8b15d562ba81ee66d55937 100755 (executable)
@@ -71,7 +71,7 @@ namespace Tizen.NUI.Binding
                         type = xamlStyle.TargetType;
                 }
                 else if (parentValuesProvider.TargetObject is Trigger)
-                    type = (parentValuesProvider.TargetObject as Trigger).TargetType;
+                    type = (parentValuesProvider.TargetObject as Trigger)?.TargetType;
                 else if (parentValuesProvider.TargetObject is XamlPropertyCondition && (parent as TriggerBase) != null)
                     type = (parent as TriggerBase).TargetType;