[NUI] Fix NUI Svace issue (#2806)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Tue, 30 Mar 2021 01:52:43 +0000 (10:52 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 30 Mar 2021 06:51:02 +0000 (15:51 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
18 files changed:
src/Tizen.NUI.Components/Controls/Navigation/Navigator.cs
src/Tizen.NUI.Components/Controls/RecyclerView/CollectionView.cs
src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs
src/Tizen.NUI/src/internal/Common/PropertyRangeManager.cs
src/Tizen.NUI/src/internal/Layouting/LayoutController.cs
src/Tizen.NUI/src/internal/XamlBinding/DependencyService.cs
src/Tizen.NUI/src/public/Common/Color.cs
src/Tizen.NUI/src/public/Common/Position.cs
src/Tizen.NUI/src/public/Common/Position2D.cs
src/Tizen.NUI/src/public/Common/RelativeVector2.cs
src/Tizen.NUI/src/public/Common/RelativeVector4.cs
src/Tizen.NUI/src/public/Common/Size.cs
src/Tizen.NUI/src/public/Common/Size2D.cs
src/Tizen.NUI/src/public/Common/Vector2.cs
src/Tizen.NUI/src/public/Layouting/FlexLayout.cs
src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs
src/Tizen.NUI/src/public/ViewProperty/Shadow.cs
src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs

index 3d10f28..1bf4f70 100755 (executable)
@@ -154,8 +154,8 @@ namespace Tizen.NUI.Components
             var newTop = NavigationPages[NavigationPages.Count - 2];
 
             //Invoke Page events
-            newTop.InvokeAppearing();
-            curTop.InvokeDisappearing();
+            newTop?.InvokeAppearing();
+            curTop?.InvokeDisappearing();
 
             //TODO: The following transition codes will be replaced with view transition.
             if (curAnimation)
index 5c30941..85fd918 100755 (executable)
@@ -762,22 +762,27 @@ namespace Tizen.NUI.Components
             }
 
             RecyclerViewItem item = base.RealizeItem(index);
-            if (isGrouped) item.ParentGroup = InternalItemSource.GetGroupParent(index);
-
-            switch (SelectionMode)
+            if (item != null)
             {
-                case ItemSelectionMode.SingleSelection:
-                    if (item.BindingContext == SelectedItem) item.IsSelected = true;
-                    break;
+                if (isGrouped)
+                {
+                    item.ParentGroup = InternalItemSource.GetGroupParent(index);
+                }
 
-                case ItemSelectionMode.MultipleSelections:
-                    if (SelectedItems?.Contains(item.BindingContext) ?? false) item.IsSelected = true;
-                    break;
-                case ItemSelectionMode.None:
-                    item.IsSelectable = false;
-                    break;
+                switch (SelectionMode)
+                {
+                    case ItemSelectionMode.SingleSelection:
+                        if (item.BindingContext == SelectedItem) item.IsSelected = true;
+                        break;
+
+                    case ItemSelectionMode.MultipleSelections:
+                        if (SelectedItems?.Contains(item.BindingContext) ?? false) item.IsSelected = true;
+                        break;
+                    case ItemSelectionMode.None:
+                        item.IsSelectable = false;
+                        break;
+                }
             }
-
             return item;
         }
 
index 7beb5bc..067c76f 100755 (executable)
@@ -350,7 +350,12 @@ namespace Tizen.NUI.Wearable
         {
             base.OnRelayout(size, container);
 
-            if (size.Width == containerSize?.Width && size.Height == containerSize.Height)
+            if (size == null || container == null || containerSize == null)
+            {
+                return;
+            }
+
+            if (size.Width == containerSize.Width && size.Height == containerSize.Height)
             {
                 return;
             }
index e56b7fb..60d00c9 100755 (executable)
@@ -106,13 +106,13 @@ namespace Tizen.NUI
             // we add 1000, just incase View class starts using animatable properties
             int startAnimatablePropertyIndex = (int)Tizen.NUI.PropertyRanges.ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + maxCountPerDerivation;
 
-            if (viewType != null)
+            while (viewType?.GetTypeInfo()?.BaseType?.Name != "CustomView")   // custom view is our C# view base class. we don't go any deeper.
             {
-                while (viewType.GetTypeInfo().BaseType?.Name != "CustomView")   // custom view is our C# view base class. we don't go any deeper.
+                // for every base class increase property start index
+                startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000
+                startAnimatablePropertyIndex += maxCountPerDerivation;
+                if (viewType != null)
                 {
-                    // for every base class increase property start index
-                    startEventPropertyIndex += (int)Tizen.NUI.PropertyRanges.DEFAULT_PROPERTY_MAX_COUNT_PER_DERIVATION; // DALi uses 10,000
-                    startAnimatablePropertyIndex += maxCountPerDerivation;
                     NUILog.Debug("getStartPropertyIndex =  " + viewType.Name + "current index " + startEventPropertyIndex);
                     viewType = viewType.GetTypeInfo().BaseType;
                 }
index ca6e17e..5cd4dee 100755 (executable)
@@ -188,25 +188,29 @@ namespace Tizen.NUI
         // Parent not a View so assume it's a Layer which is the size of the window.
         void MeasureAndLayout(View root, float parentWidth, float parentHeight)
         {
-            float positionX = root.PositionX;
-            float positionY = root.PositionY;
-
-            // Determine measure specification for root.
-            // The root layout policy could be an exact size, be match parent or wrap children.
-            // If wrap children then at most it can be the root parent size.
-            // If match parent then should be root parent size.
-            // If exact then should be that size limited by the root parent size.
-            MeasureSpecification parentWidthSpecification = CreateMeasureSpecification(parentWidth, root.WidthSpecification);
-            MeasureSpecification parentHeightSpecification = CreateMeasureSpecification(parentHeight, root.HeightSpecification);
-
-            // Start at root with it's parent's widthSpecification and heightSpecification
-            MeasureHierarchy(root, parentWidthSpecification, parentHeightSpecification);
-
-            // Start at root which was just measured.
-            PerformLayout(root, new LayoutLength(positionX),
-                                 new LayoutLength(positionY),
-                                 new LayoutLength(positionX) + root.Layout.MeasuredWidth.Size,
-                                 new LayoutLength(positionY) + root.Layout.MeasuredHeight.Size);
+            if (root.Layout != null)
+            {
+                float positionX = root.PositionX;
+                float positionY = root.PositionY;
+
+                // Determine measure specification for root.
+                // The root layout policy could be an exact size, be match parent or wrap children.
+                // If wrap children then at most it can be the root parent size.
+                // If match parent then should be root parent size.
+                // If exact then should be that size limited by the root parent size.
+                MeasureSpecification parentWidthSpecification = CreateMeasureSpecification(parentWidth, root.WidthSpecification);
+                MeasureSpecification parentHeightSpecification = CreateMeasureSpecification(parentHeight, root.HeightSpecification);
+
+                // Start at root with it's parent's widthSpecification and heightSpecification
+                MeasureHierarchy(root, parentWidthSpecification, parentHeightSpecification);
+
+                // Start at root which was just measured.
+                PerformLayout(root, new LayoutLength(positionX),
+                                     new LayoutLength(positionY),
+                                     new LayoutLength(positionX) + root.Layout.MeasuredWidth.Size,
+                                     new LayoutLength(positionY) + root.Layout.MeasuredHeight.Size);
+
+            }
 
             if (SetupCoreAnimation() && OverrideCoreAnimation == false)
             {
index a354a75..61164e2 100755 (executable)
@@ -94,7 +94,7 @@ namespace Tizen.NUI.Binding
             }
 
             Assembly[] assemblies = Device.GetAssemblies();
-            if (Tizen.NUI.Binding.Internals.Registrar.ExtraAssemblies != null)
+            if (assemblies != null && Tizen.NUI.Binding.Internals.Registrar.ExtraAssemblies != null)
             {
                 assemblies = assemblies.Union(Tizen.NUI.Binding.Internals.Registrar.ExtraAssemblies).ToArray();
             }
index c81c0a2..d684246 100755 (executable)
@@ -1056,8 +1056,9 @@ namespace Tizen.NUI
         /// The copy constructor.
         /// </summary>
         /// <param name="other">The copy target.</param>
+        /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Color(Color other) : this((float)other?.R, (float)other.G, (float)other.B, (float)other.A)
+        public Color(Color other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.R, other.G, other.B, other.A)
         {
         }
 
@@ -1232,7 +1233,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector4(Color color)
         {
-            return new Vector4((float)color?.R, (float)color.G, (float)color.B, (float)color.A);
+            if (color == null)
+            {
+                return null;
+            }
+            return new Vector4(color.R, color.G, color.B, color.A);
         }
 
         /// <summary>
@@ -1242,7 +1247,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Color(Vector4 vec)
         {
-            return new Color((float)vec?.R, (float)vec.G, (float)vec.B, (float)vec.A);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new Color(vec.R, vec.G, vec.B, vec.A);
         }
 
         /// <summary>
index 22fc0d8..7929341 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -787,9 +787,13 @@ namespace Tizen.NUI
         /// Converts a position instance to a Vector3 instance.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public static implicit operator Vector3(Position Position)
+        public static implicit operator Vector3(Position position)
         {
-            return new Vector3((float)Position?.X, (float)Position.Y, (float)Position.Z);
+            if (position == null)
+            {
+                return null;
+            }
+            return new Vector3(position.X, position.Y, position.Z);
         }
 
         /// <summary>
@@ -798,7 +802,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Position(Vector3 vec)
         {
-            return new Position((float)vec?.X, (float)vec.Y, (float)vec.Z);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new Position(vec.X, vec.Y, vec.Z);
         }
 
         /// <summary>
@@ -810,7 +818,11 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static implicit operator Position(Position2D position2d)
         {
-            return new Position((float)position2d?.X, (float)position2d.Y, 0);
+            if (position2d == null)
+            {
+                return null;
+            }
+            return new Position(position2d.X, position2d.Y, 0);
         }
 
         /// <summary>
index c0d9f49..8fe984b 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -337,7 +337,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector2(Position2D position2d)
         {
-            return new Vector2((float)position2d?.X, (float)position2d.Y);
+            if (position2d == null)
+            {
+                return null;
+            }
+            return new Vector2(position2d.X, position2d.Y);
         }
 
         /// <summary>
@@ -348,7 +352,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Position2D(Vector2 vec)
         {
-            return new Position2D((int)vec?.X, (int)vec.Y);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new Position2D((int)vec.X, (int)vec.Y);
         }
 
         /// <summary>
@@ -360,7 +368,11 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static implicit operator Position2D(Position position)
         {
-            return new Position2D((int)position?.X, (int)position.Y);
+            if (position == null)
+            {
+                return null;
+            }
+            return new Position2D((int)position.X, (int)position.Y);
         }
 
         /// <inheritdoc/>
index b34ca59..64202cf 100755 (executable)
@@ -224,7 +224,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector2(RelativeVector2 relativeVector2)
         {
-            return new Vector2((float)relativeVector2?.X, (float)relativeVector2.Y);
+            if (relativeVector2 == null)
+            {
+                return null;
+            }
+            return new Vector2(relativeVector2.X, relativeVector2.Y);
         }
 
         /// <summary>
@@ -232,7 +236,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator RelativeVector2(Vector2 vec)
         {
-            return new RelativeVector2((float)vec?.X, (float)vec.Y);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new RelativeVector2(vec.X, vec.Y);
         }
 
         /// <summary>
index 12c9429..12f4815 100755 (executable)
@@ -298,7 +298,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector4(RelativeVector4 relativeVector4)
         {
-            return new Vector4((float)relativeVector4?.X, (float)relativeVector4.Y, (float)relativeVector4.Z, (float)relativeVector4.W);
+            if (relativeVector4 == null)
+            {
+                return null;
+            }
+            return new Vector4(relativeVector4.X, relativeVector4.Y, relativeVector4.Z, relativeVector4.W);
         }
 
         /// <summary>
@@ -306,7 +310,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator RelativeVector4(Vector4 vec)
         {
-            return new RelativeVector4((float)vec?.X, (float)vec.Y, (float)vec.Z, (float)vec.W);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new RelativeVector4(vec.X, vec.Y, vec.Z, vec.W);
         }
 
         /// <summary>
index 37ddf0b..f687966 100755 (executable)
@@ -355,7 +355,11 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static implicit operator Vector3(Size size)
         {
-            return new Vector3((float)size?.Width, (float)size.Height, (float)size.Depth);
+            if (size == null)
+            {
+                return null;
+            }
+            return new Vector3(size.Width, size.Height, size.Depth);
         }
 
         /// <summary>
@@ -365,7 +369,11 @@ namespace Tizen.NUI
         /// <since_tizen> 5 </since_tizen>
         public static implicit operator Size(Vector3 vec)
         {
-            return new Size((int)vec?.Width, (int)vec.Height, (int)vec.Depth);
+            if (vec == null)
+            {
+                return null;
+            }
+            return new Size(vec.Width, vec.Height, vec.Depth);
         }
 
         /// <summary>
@@ -377,7 +385,11 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static implicit operator Size(Size2D size2d)
         {
-            return new Size((int)size2d?.Width, (int)size2d.Height, 0);
+            if (size2d == null)
+            {
+                return null;
+            }
+            return new Size(size2d.Width, size2d.Height);
         }
 
 
index 8e00d5b..4c7e459 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -228,7 +228,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Vector2(Size2D size)
         {
-            return new Vector2((float)size?.Width, (float)size.Height);
+            if (size == null)
+            {
+                return null;
+            }
+            return new Vector2(size.Width, size.Height);
         }
 
         /// <summary>
@@ -239,7 +243,11 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public static implicit operator Size2D(Vector2 vector2)
         {
-            return new Size2D((int)vector2?.X, (int)vector2.Y);
+            if (vector2 == null)
+            {
+                return null;
+            }
+            return new Size2D((int)vector2.X, (int)vector2.Y);
         }
 
         /// <summary>
@@ -251,7 +259,11 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static implicit operator Size2D(Size size)
         {
-            return new Size2D((int)size?.Width, (int)size.Height);
+            if (size == null)
+            {
+                return null;
+            }
+            return new Size2D((int)size.Width, (int)size.Height);
         }
 
 
index 2645417..92a1abe 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
@@ -63,8 +63,9 @@ namespace Tizen.NUI
         /// The copy constructor.
         /// </summary>
         /// <param name="other">The copy target.</param>
+        /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Vector2(Vector2 other) : this((float)other?.X, (float)other.Y)
+        public Vector2(Vector2 other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.X, other.Y)
         {
         }
 
index 311152c..dc3da47 100755 (executable)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/* Copyright (c) 2021 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.
@@ -642,7 +642,7 @@ namespace Tizen.NUI
             // We need to measure child layout
             View child = Registry.GetManagedBaseHandleFromNativePtr(childPtr) as View;
             // independent child will be measured in LayoutGroup.OnMeasureIndependentChildren().
-            if (child?.ExcludeLayouting ?? true)
+            if ((child == null) || (child?.ExcludeLayouting ?? true))
             {
                 measureSize.width = 0;
                 measureSize.height = 0;
index b0e8387..a5d3743 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
@@ -72,8 +72,9 @@ namespace Tizen.NUI
         /// <summary>
         /// Constructor
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public ImageShadow(ImageShadow other) : this(other?.Url, other.Border, other.Offset, other.Extents)
+        public ImageShadow(ImageShadow other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.Url, other.Border, other.Offset, other.Extents)
         {
         }
 
index 0ef8581..586e2cc 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
@@ -54,8 +54,9 @@ namespace Tizen.NUI
         /// <summary>
         /// Copy constructor.
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public Shadow(Shadow other) : this((float)other?.BlurRadius, other.Offset, other.Color, other.Extents)
+        public Shadow(Shadow other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.BlurRadius, other.Offset, other.Color, other.Extents)
         {
         }
 
index f9de1b1..32bc8e1 100755 (executable)
@@ -15,6 +15,7 @@
  *
  */
 
+using System;
 using System.ComponentModel;
 using System.Diagnostics;
 
@@ -81,8 +82,9 @@ namespace Tizen.NUI
         /// <summary>
         /// Copy Constructor
         /// </summary>
+        /// <exception cref="ArgumentNullException"> Thrown when other is null. </exception>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        protected ShadowBase(ShadowBase other) : this(other?.Offset, other.Extents)
+        protected ShadowBase(ShadowBase other) : this(other == null ? throw new ArgumentNullException(nameof(other)) : other.Offset, other.Extents)
         {
         }