[NUI] Fix WidthSpecification and HeightSpecification setting issue. (#1982)
authorbshsqa <32317749+bshsqa@users.noreply.github.com>
Mon, 7 Sep 2020 06:22:18 +0000 (15:22 +0900)
committerGitHub <noreply@github.com>
Mon, 7 Sep 2020 06:22:18 +0000 (15:22 +0900)
- Currently, new Size2D is created when one of the WidthSpecification or HeightSpecification is set.
 - Then, the Size2D has incomplete value until the latter one is also entered.
 - e.g. if the size is (500, 500), after just WidthSpecification is entered the Size2D is (500, -2) until HeightSpecification will be entered.
 - (-2 is default negative value that notifing the value is still not set).

 - But, in the property setter of Size2D in View, the value is transfered to the Native API.
 - And the incomplete value make crash in Native API.
 - Because when the latter is entered, we just set Size2D.Width or Size2D.Height not to create Size2D itself. And, exact Size2D is not transfered to the Native.

 - So, this patch postpone to create Size2D utill both WidthSpecification and HeightSpecification are all entered.
 - This create new Size2D whenever new WidthSpecification or HeightSpecification is entered, and it transfers them to the Native well.

Signed-off-by: seungho <seungho@seungho.tn.corp.samsungelectronics.net>
Co-authored-by: seungho <seungho@seungho.tn.corp.samsungelectronics.net>
Co-authored-by: dongsug-song <35130733+dongsug-song@users.noreply.github.com>
src/Tizen.NUI/src/public/BaseComponents/View.cs

index 306985a..3384635 100755 (executable)
@@ -782,6 +782,7 @@ namespace Tizen.NUI.BaseComponents
                 MeasureSpecificationHeight = new MeasureSpecification(new LayoutLength(value.Height), MeasureSpecification.ModeType.Exactly);
                 _widthPolicy = value.Width;
                 _heightPolicy = value.Height;
+                
                 _layout?.RequestLayout();
                 NotifyPropertyChanged();
             }
@@ -1954,13 +1955,7 @@ namespace Tizen.NUI.BaseComponents
 
                         if(_heightPolicy>=0) // Policy an exact value
                         {
-                            Size2D.Width = _widthPolicy;
-                        }
-                        else
-                        {
-                            // Store _heightPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
-                            // Size2D height will store the specification value (negative number) this will then be applied to the
-                            // HeightSpecification when the Size2D callback is invoked.
+                            // Create Size2D only both _widthPolicy and _heightPolicy are set.
                             Size2D = new Size2D(_widthPolicy,_heightPolicy);
                         }
                     }
@@ -1991,13 +1986,7 @@ namespace Tizen.NUI.BaseComponents
 
                         if(_widthPolicy>=0) // Policy an exact value
                         {
-                            Size2D.Height = _heightPolicy;
-                        }
-                        else
-                        {
-                            // Store widthPolicy in the Size2D memember as will be reset to 0 by a Size2D callback.
-                            // Size2D height will store the specification value (negative number) this will then be applied to the
-                            // HeightSpecification when the Size2D callback is invoked.
+                            // Create Size2D only both _widthPolicy and _heightPolicy are set.
                             Size2D = new Size2D(_widthPolicy,_heightPolicy);
                         }