[NUI] Fix some CA2000 warnings in NUI.
authorhuayong.xu <huayong.xu@samsung.com>
Mon, 28 Apr 2025 08:12:01 +0000 (16:12 +0800)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 14 May 2025 06:35:12 +0000 (15:35 +0900)
Meanwhile some memory leaks are fixed. For example,
Vector2.Dispose is not called in Wheel constructor.

src/Tizen.NUI/src/internal/Animation/Constraint.cs
src/Tizen.NUI/src/public/Common/PropertyArray.cs
src/Tizen.NUI/src/public/Events/Wheel.cs
src/Tizen.NUI/src/public/Utility/Capture.cs
src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs
src/Tizen.NUI/src/public/Visuals/VisualObject/AnimatedImageVisual.cs
src/Tizen.NUI/src/public/Window/MouseInOut.cs
src/Tizen.NUI/src/public/Window/MouseRelative.cs

index 4ffd6b65d529b86f851281a9423680f2c0cc30d5..69796ced3c7f76aac6223e938fefea3405605323 100755 (executable)
@@ -467,13 +467,14 @@ namespace Tizen.NUI
             if (ret != null)
             {
                 Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr));
+                NDalicPINVOKE.ThrowExceptionIfExists();
+                return ret;
             }
             else
             {
                 ret = new Animatable(cPtr, true);
+                return ret;
             }
-            NDalicPINVOKE.ThrowExceptionIfExists();
-            return ret;
         }
 
         /// <summary>
index b499d38e97b2e7ae15b2743c40d1b25b7f2e1d68..a2af5447a1a3767d943f118611beca3cb41e4fc8 100755 (executable)
@@ -173,7 +173,6 @@ namespace Tizen.NUI
         public PropertyArray Add(PropertyValue value)
         {
             PropertyArray ret = new PropertyArray(Interop.Property.ArrayAdd(SwigCPtr, PropertyValue.getCPtr(value)), false);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
 
index a07b7b67220be1871b41a36afa09c4418761ec57..141528daf525be114a91213912f3281885486022 100755 (executable)
@@ -28,12 +28,11 @@ namespace Tizen.NUI
     /// <since_tizen> 3 </since_tizen>
     public class Wheel : BaseHandle
     {
-
         /// <summary>
         /// The default constructor of Wheel class.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        public Wheel() : this(Interop.Wheel.New(0, 0, 0u, Vector2.getCPtr(new Vector2(0.0f, 0.0f)), 0, 0u), true)
+        public Wheel() : this(Interop.Wheel.New(0, 0, 0u, Vector2.getCPtr(Vector2.Zero), 0, 0u), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
index e618ac649ab773b858bb666bde422a8f288fed08..0b9d2275bd4da9beb4aaf3e5b0830aadfd952e3c 100755 (executable)
@@ -154,7 +154,8 @@ namespace Tizen.NUI
             {
                 using var posVector2 = new Vector2(position.X, position.Y);
                 using var sizeVector2 = new Vector2(size.Width, size.Height);
-                Interop.Capture.Start4(SwigCPtr, source.SwigCPtr, posVector2.SwigCPtr, sizeVector2.SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr);
+                using var colorVector4 = new Vector4(color.R, color.G, color.B, color.A);
+                Interop.Capture.Start4(SwigCPtr, source.SwigCPtr, posVector2.SwigCPtr, sizeVector2.SwigCPtr, path, colorVector4.SwigCPtr);
 
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
@@ -199,7 +200,8 @@ namespace Tizen.NUI
             if (source is View || source is Layer)
             {
                 using var sizeVector2 = new Vector2(size.Width, size.Height);
-                Interop.Capture.Start3(SwigCPtr, source.SwigCPtr, sizeVector2.SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr, quality);
+                using var colorVector4 = new Vector4(color.R, color.G, color.B, color.A);
+                Interop.Capture.Start3(SwigCPtr, source.SwigCPtr, sizeVector2.SwigCPtr, path, colorVector4.SwigCPtr, quality);
 
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
@@ -239,7 +241,8 @@ namespace Tizen.NUI
             if (source is View || source is Layer)
             {
                 using var sizeVector2 = new Vector2(size.Width, size.Height);
-                Interop.Capture.Start1(SwigCPtr, source.SwigCPtr, sizeVector2.SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr);
+                using var colorVector4 = new Vector4(color.R, color.G, color.B, color.A);
+                Interop.Capture.Start1(SwigCPtr, source.SwigCPtr, sizeVector2.SwigCPtr, path, colorVector4.SwigCPtr);
 
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
index 8182f619499d2b6005e179b83789f1c26d22980c..39bc1b27fd2ab7d01d92f059f09e3d6e48587fcf 100755 (executable)
@@ -176,8 +176,10 @@ namespace Tizen.NUI
                     using var urlArray = new PropertyArray();
                     foreach (var url in urls)
                     {
-                        var pv = new PropertyValue(url);
-                        using var _ = urlArray.Add(pv);
+                        using (var pv = new PropertyValue(url))
+                        {
+                            using var _ = urlArray.Add(pv);
+                        }
                     }
                     using (var temp = new PropertyValue(urlArray))
                     {
index fd1ceb0898be0e790bba10be575f606abe670dd2..5caa04b27fb7990affb60376982662edda2df6a6 100644 (file)
@@ -296,8 +296,10 @@ namespace Tizen.NUI.Visuals
                 using var urlArray = new PropertyArray();
                 foreach (var url in resourceUrls)
                 {
-                    var urlValue = new PropertyValue(url);
-                    using var _ = urlArray.Add(urlValue);
+                    using (var urlValue = new PropertyValue(url))
+                    {
+                        using var _ = urlArray.Add(urlValue);
+                    }
                 }
 
                 if (cachedVisualPropertyMap != null)
index 31e5dfe4fb8dbf8af06586e6b619476b7729265e..053d75346fdd788219f31adf9e2fb7a70a3b3195 100755 (executable)
@@ -25,12 +25,11 @@ namespace Tizen.NUI
     [EditorBrowsable(EditorBrowsableState.Never)]
     public class MouseInOut : Disposable
     {
-
         /// <summary>
         /// The default constructor.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public MouseInOut() : this(Interop.MouseInOut.NewMouseInOut((int)MouseInOut.StateType.None, 0, Vector2.getCPtr(new Vector2(0, 0)), 0), true)
+        public MouseInOut() : this(Interop.MouseInOut.NewMouseInOut((int)MouseInOut.StateType.None, 0, Vector2.getCPtr(Vector2.Zero), 0), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
index 8ec7a992d9ec4286ab141e2a1adbee1b05821090..258603f2f24e580aa4bb53f574413a9c34148a36 100755 (executable)
@@ -25,12 +25,11 @@ namespace Tizen.NUI
     [EditorBrowsable(EditorBrowsableState.Never)]
     public class MouseRelative : Disposable
     {
-
         /// <summary>
         /// The default constructor.
         /// </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
-        public MouseRelative() : this(Interop.MouseRelative.NewMouseRelative((int)MouseRelative.StateType.None, 0, 0, Vector2.getCPtr(new Vector2(0, 0)), Vector2.getCPtr(new Vector2(0, 0))), true)
+        public MouseRelative() : this(Interop.MouseRelative.NewMouseRelative((int)MouseRelative.StateType.None, 0, 0, Vector2.getCPtr(Vector2.Zero), Vector2.getCPtr(Vector2.Zero)), true)
         {
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }