[NUI] fix warning about internal methods of text components
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 31 Dec 2021 10:36:48 +0000 (19:36 +0900)
committerSeoyeon2Kim <34738918+Seoyeon2Kim@users.noreply.github.com>
Wed, 12 Jan 2022 08:40:18 +0000 (17:40 +0900)
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs

index 2b38724..c063ca3 100755 (executable)
@@ -1599,8 +1599,11 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                SetProperty(TextEditor.Property.EnableEditing, new PropertyValue(value));
-                NotifyPropertyChanged();
+                using (var propertyValue = new PropertyValue(value))
+                {
+                    SetProperty(TextEditor.Property.EnableEditing, propertyValue);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -1758,10 +1761,9 @@ namespace Tizen.NUI.BaseComponents
         public void SetInputFilter(InputFilter inputFilter)
         {
             using (var map = TextMapHelper.GetInputFilterMap(inputFilter))
+            using (var propertyValue = new PropertyValue(map))
             {
-                var propertyValue = new PropertyValue(map);
                 SetProperty(TextEditor.Property.InputFilter, propertyValue);
-                propertyValue.Dispose();
             }
         }
 
@@ -1777,11 +1779,10 @@ namespace Tizen.NUI.BaseComponents
         {
             InputFilter inputFilter;
             using (var propertyValue = GetProperty(TextEditor.Property.InputFilter))
+            using (var map = new PropertyMap())
             {
-                var map = new PropertyMap();
                 propertyValue.Get(map);
                 inputFilter = TextMapHelper.GetInputFilterStruct(map);
-                map.Dispose();
             }
             return inputFilter;
         }
@@ -1836,19 +1837,27 @@ namespace Tizen.NUI.BaseComponents
                     map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
                 
                 if (TextMapHelper.IsValue(map, 2))
-                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2));
+                {
+                    using (var color = TextMapHelper.GetColorFromMap(map, 2))
+                    {
+                        map.Add("color", color);
+                    }
+                }
                 
                 if (TextMapHelper.IsValue(map, 3))
                     map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
 
                 if (TextMapHelper.IsValue(map, 4))
                 {
-                    var fontStyle = new PropertyMap();
-                    map.Find(4).Get(fontStyle);
-                    var fontStyleValue = new PropertyValue(fontStyle);
-                    map.Add("fontStyle", fontStyleValue);
-                    fontStyleValue.Dispose();
-                    fontStyle.Dispose();
+                    using (var properyValue = map.Find(4))
+                    using (var fontStyle = new PropertyMap())
+                    {
+                        properyValue.Get(fontStyle);
+                        using (var fontStyleValue = new PropertyValue(fontStyle))
+                        {
+                            map.Add("fontStyle", fontStyleValue);
+                        }
+                    }
                 }
 
                 if (TextMapHelper.IsValue(map, 5))
index d53a58f..36c4fa9 100755 (executable)
@@ -515,18 +515,29 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                PropertyMap map = new PropertyMap();
-                GetProperty(TextField.Property.SHADOW).Get(map);
-                Vector2 shadowOffset = new Vector2();
-                map.Find(TextField.Property.SHADOW, "offset")?.Get(shadowOffset);
-                return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
+                float x = 0.0f, y = 0.0f;
+                using (var propertyValue = Shadow.Find(TextField.Property.SHADOW, "offset"))
+                using (var shadowOffset = new Vector2())
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(shadowOffset);
+                        x = shadowOffset.X;
+                        y = shadowOffset.Y;
+                    }
+                }
+                return new Vector2(OnShadowOffsetChanged, x, y);
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("offset", new PropertyValue(value));
-                SetValue(ShadowProperty, temp);
-                NotifyPropertyChanged();
+                using (var map = new PropertyMap())
+                {
+                    map.Add("offset", value);
+                    var shadowMap = Shadow;
+                    shadowMap.Merge(map);
+                    SetValue(ShadowProperty, shadowMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -555,18 +566,31 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                PropertyMap map = new PropertyMap();
-                GetProperty(TextField.Property.SHADOW).Get(map);
-                Vector4 shadowColor = new Vector4();
-                map.Find(TextField.Property.SHADOW, "color")?.Get(shadowColor);
-                return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
+                float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
+                using (var propertyValue = Shadow.Find(TextField.Property.SHADOW, "color"))
+                using (var shadowColor = new Vector4())
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(shadowColor);
+                        x = shadowColor.X;
+                        y = shadowColor.Y;
+                        z = shadowColor.Z;
+                        w = shadowColor.W;
+                    }
+                }
+                return new Vector4(OnShadowColorChanged, x, y, z, w);
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("color", new PropertyValue(value));
-                SetValue(ShadowProperty, temp);
-                NotifyPropertyChanged();
+                using (var map = new PropertyMap())
+                {
+                    map.Add("color", value);
+                    var shadowMap = Shadow;
+                    shadowMap.Merge(map);
+                    SetValue(ShadowProperty, shadowMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -1818,8 +1842,11 @@ namespace Tizen.NUI.BaseComponents
             }
             set
             {
-                SetProperty(TextField.Property.EnableEditing, new PropertyValue(value));
-                NotifyPropertyChanged();
+                using (var propertyValue = new PropertyValue(value))
+                {
+                    SetProperty(TextField.Property.EnableEditing, propertyValue);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -1921,10 +1948,9 @@ namespace Tizen.NUI.BaseComponents
         public void SetInputFilter(InputFilter inputFilter)
         {
             using (var map = TextMapHelper.GetInputFilterMap(inputFilter))
+            using (var propertyValue = new PropertyValue(map))
             {
-                var propertyValue = new PropertyValue(map);
                 SetProperty(TextField.Property.InputFilter, propertyValue);
-                propertyValue.Dispose();
             }
         }
 
@@ -1940,11 +1966,10 @@ namespace Tizen.NUI.BaseComponents
         {
             InputFilter inputFilter;
             using (var propertyValue = GetProperty(TextField.Property.InputFilter))
+            using (var map = new PropertyMap())
             {
-                var map = new PropertyMap();
                 propertyValue.Get(map);
                 inputFilter = TextMapHelper.GetInputFilterStruct(map);
-                map.Dispose();
             }
             return inputFilter;
         }
@@ -1999,19 +2024,27 @@ namespace Tizen.NUI.BaseComponents
                     map.Add("textFocused", TextMapHelper.GetStringFromMap(map, 1, defalutText));
                 
                 if (TextMapHelper.IsValue(map, 2))
-                    map.Add("color", TextMapHelper.GetColorFromMap(map, 2));
-                
+                {
+                    using (var color = TextMapHelper.GetColorFromMap(map, 2))
+                    {
+                        map.Add("color", color);
+                    }
+                }
+
                 if (TextMapHelper.IsValue(map, 3))
                     map.Add("fontFamily", TextMapHelper.GetStringFromMap(map, 3, defalutText));
 
                 if (TextMapHelper.IsValue(map, 4))
                 {
-                    var fontStyle = new PropertyMap();
-                    map.Find(4).Get(fontStyle);
-                    var fontStyleValue = new PropertyValue(fontStyle);
-                    map.Add("fontStyle", fontStyleValue);
-                    fontStyleValue.Dispose();
-                    fontStyle.Dispose();
+                    using (var properyValue = map.Find(4))
+                    using (var fontStyle = new PropertyMap())
+                    {
+                        properyValue.Get(fontStyle);
+                        using (var fontStyleValue = new PropertyValue(fontStyle))
+                        {
+                            map.Add("fontStyle", fontStyleValue);
+                        }
+                    }
                 }
 
                 if (TextMapHelper.IsValue(map, 5))
index 01ac366..200cd7c 100755 (executable)
@@ -440,20 +440,31 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                Vector2 shadowOffset = new Vector2();
-                Shadow.Find(TextLabel.Property.SHADOW, "offset")?.Get(shadowOffset);
-                return new Vector2(OnShadowOffsetChanged, shadowOffset.X, shadowOffset.Y);
+                float x = 0.0f, y = 0.0f;
+                using (var propertyValue = Shadow.Find(TextLabel.Property.SHADOW, "offset"))
+                using (var shadowOffset = new Vector2())
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(shadowOffset);
+                        x = shadowOffset.X;
+                        y = shadowOffset.Y;
+                    }
+                }
+                return new Vector2(OnShadowOffsetChanged, x, y);
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("offset", new PropertyValue(value));
+                using (var map = new PropertyMap())
+                {
+                    map.Add("offset", value);
 
-                PropertyMap shadowMap = Shadow;
-                shadowMap.Merge(temp);
+                    var shadowMap = Shadow;
+                    shadowMap.Merge(map);
 
-                SetValue(ShadowProperty, shadowMap);
-                NotifyPropertyChanged();
+                    SetValue(ShadowProperty, shadowMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -483,20 +494,31 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                Vector4 shadowColor = new Vector4();
-                Shadow.Find(TextLabel.Property.SHADOW, "color")?.Get(shadowColor);
-                return new Vector4(OnShadowColorChanged, shadowColor.X, shadowColor.Y, shadowColor.Z, shadowColor.W);
+                float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
+                using (var propertyValue = Shadow.Find(TextLabel.Property.SHADOW, "color"))
+                using (var shadowColor = new Vector4())
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(shadowColor);
+                        x = shadowColor.X;
+                        y = shadowColor.Y;
+                        z = shadowColor.Z;
+                        w = shadowColor.W;
+                    }
+                }
+                return new Vector4(OnShadowColorChanged, x, y, z, w);
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("color", new PropertyValue(value));
-
-                PropertyMap shadowMap = Shadow;
-                shadowMap.Merge(temp);
-
-                SetValue(ShadowProperty, shadowMap);
-                NotifyPropertyChanged();
+                using (var map = new PropertyMap())
+                {
+                    map.Add("color", value);
+                    var shadowMap = Shadow;
+                    shadowMap.Merge(map);
+                    SetValue(ShadowProperty, shadowMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -526,20 +548,22 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 bool underlineEnabled = false;
-                Underline.Find(TextLabel.Property.UNDERLINE, "enable")?.Get(out underlineEnabled);
+                using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "enable"))
+                {
+                    propertyValue.Get(out underlineEnabled);
+                }
                 return underlineEnabled;
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Add("enable", new PropertyValue(value));
-
-                PropertyMap undelineMap = Underline;
-                undelineMap.Merge(temp);
-
-                SetValue(UnderlineProperty, undelineMap);
-                NotifyPropertyChanged();
-
+                using (var map = new PropertyMap())
+                {
+                    map.Add("enable", value);
+                    var undelineMap = Underline;
+                    undelineMap.Merge(map);
+                    SetValue(UnderlineProperty, undelineMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -569,20 +593,31 @@ namespace Tizen.NUI.BaseComponents
         {
             get
             {
-                Vector4 underlineColor = new Vector4();
-                Underline.Find(TextLabel.Property.UNDERLINE, "color")?.Get(underlineColor);
-                return new Vector4(OnUnderlineColorChanged, underlineColor.X, underlineColor.Y, underlineColor.Z, underlineColor.W);
+                float x = 0.0f, y = 0.0f, z = 0.0f, w = 0.0f;
+                using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "color"))
+                using (var underlineColor = new Vector4())
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(underlineColor);
+                        x = underlineColor.X;
+                        y = underlineColor.Y;
+                        z = underlineColor.Z;
+                        w = underlineColor.W;
+                    }
+                }
+                return new Vector4(OnUnderlineColorChanged, x, y, z, w);
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("color", new PropertyValue(value));
-
-                PropertyMap undelineMap = Underline;
-                undelineMap.Merge(temp);
-
-                SetValue(UnderlineProperty, undelineMap);
-                NotifyPropertyChanged();
+                using (var map = new PropertyMap())
+                {
+                    map.Add("color", value);
+                    var undelineMap = Underline;
+                    undelineMap.Merge(map);
+                    SetValue(UnderlineProperty, undelineMap);
+                    NotifyPropertyChanged();
+                }
             }
         }
 
@@ -612,19 +647,25 @@ namespace Tizen.NUI.BaseComponents
             get
             {
                 float underlineHeight = 0.0f;
-                Underline.Find(TextLabel.Property.UNDERLINE, "height")?.Get(out underlineHeight);
+                using (var propertyValue = Underline.Find(TextLabel.Property.UNDERLINE, "height"))
+                {
+                    if (null != propertyValue)
+                    {
+                        propertyValue.Get(out underlineHeight);
+                    }
+                }
                 return underlineHeight;
             }
             set
             {
-                PropertyMap temp = new PropertyMap();
-                temp.Insert("height", new PropertyValue(value));
-
-                PropertyMap undelineMap = Underline;
-                undelineMap.Merge(temp);
-
-                SetValue(UnderlineProperty, undelineMap);
-                NotifyPropertyChanged();
+                using (var map = new PropertyMap())
+                {
+                    map.Add("height", value);
+                    var undelineMap = Underline;
+                    undelineMap.Merge(map);
+                    SetValue(UnderlineProperty, undelineMap);
+                    NotifyPropertyChanged();
+                }
             }
         }