From aa43edb366c8f61044860ff511d142ac4678545b Mon Sep 17 00:00:00 2001 From: "huayong.xu" Date: Mon, 7 Apr 2025 16:41:02 +0800 Subject: [PATCH] [NUI] Fix more CA2000 warnings in NUI. After this patch, about 87 CA2000 warnings are remaining in VS. --- .../BaseComponents/View_Deprecated.cs | 5 ++-- src/Tizen.NUI/src/devel/Lite/UIShadow.cs | 8 ++++++- .../src/internal/Application/Application.cs | 3 +-- .../internal/Common/VisualObjectsContainer.cs | 12 ++++++---- .../Transition/TransitionGroupItem.cs | 2 +- .../public/Application/NUIWidgetComponent.cs | 4 ++-- .../src/public/BaseComponents/ImageView.cs | 3 ++- .../BaseComponents/LottieAnimationView.cs | 24 ++++++++++++------- .../src/public/BaseComponents/View.cs | 16 ++++++++----- .../BaseComponents/ViewBindableProperty.cs | 16 +++++++++---- .../BaseComponents/ViewPublicMethods.cs | 10 ++++---- .../src/public/Common/TypeRegistry.cs | 12 +++++----- .../public/ParticleSystem/ParticleEmitter.cs | 7 +++--- src/Tizen.NUI/src/public/Utility/Capture.cs | 18 +++++++++----- .../src/public/Visuals/AnimatedImageVisual.cs | 6 ++--- .../src/public/Visuals/VisualFactory.cs | 6 ++--- .../VisualObject/AnimatedImageVisual.cs | 4 ++-- .../Visuals/VisualObject/BorderVisual.cs | 6 +++-- .../public/Visuals/VisualObject/VisualBase.cs | 3 ++- src/Tizen.NUI/src/public/Window/Window.cs | 7 +++--- .../src/public/Window/WindowEvent.cs | 5 +++- 21 files changed, 110 insertions(+), 67 deletions(-) diff --git a/src/Tizen.NUI/src/deprecated/BaseComponents/View_Deprecated.cs b/src/Tizen.NUI/src/deprecated/BaseComponents/View_Deprecated.cs index 542ed3625..acf8543af 100644 --- a/src/Tizen.NUI/src/deprecated/BaseComponents/View_Deprecated.cs +++ b/src/Tizen.NUI/src/deprecated/BaseComponents/View_Deprecated.cs @@ -70,13 +70,14 @@ namespace Tizen.NUI.BaseComponents if (ret != null) { Interop.BaseHandle.DeleteBaseHandle(new HandleRef(this, cPtr)); + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; } else { ret = new Renderer(cPtr, true); + return ret; } - NDalicPINVOKE.ThrowExceptionIfExists(); - return ret; } /// diff --git a/src/Tizen.NUI/src/devel/Lite/UIShadow.cs b/src/Tizen.NUI/src/devel/Lite/UIShadow.cs index 53640ee5d..0f27c2bd7 100644 --- a/src/Tizen.NUI/src/devel/Lite/UIShadow.cs +++ b/src/Tizen.NUI/src/devel/Lite/UIShadow.cs @@ -211,7 +211,13 @@ namespace Tizen.NUI return !operand1.Equals(operand2); } - internal readonly NUI.Shadow ToShadow() => new NUI.Shadow(BlurRadius, Color.ToReferenceType(), new (OffsetX, OffsetY), new (ExtraWidth, ExtraHeight)); + internal readonly NUI.Shadow ToShadow() + { + using var color = Color.ToReferenceType(); + using Vector2 offset = new(OffsetX, OffsetY); + using Vector2 extents = new(ExtraWidth, ExtraHeight); + return new NUI.Shadow(BlurRadius, color, offset, extents); + } internal readonly PropertyMap BuildMap(View attachedView) { diff --git a/src/Tizen.NUI/src/internal/Application/Application.cs b/src/Tizen.NUI/src/internal/Application/Application.cs index 66cda0d1a..9ea05af3d 100755 --- a/src/Tizen.NUI/src/internal/Application/Application.cs +++ b/src/Tizen.NUI/src/internal/Application/Application.cs @@ -1944,10 +1944,9 @@ namespace Tizen.NUI } // It will be removed until dali APIs are prepared. - Rectangle initRectangle = new Rectangle(0, 0, 0, 0); + using Rectangle initRectangle = new Rectangle(0, 0, 0, 0); Application ret = new Application(Interop.Application.New(argc, argvStr, stylesheet, (int)windowMode, Rectangle.getCPtr(initRectangle), (int)type), true); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } diff --git a/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs b/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs index 2d1a31eeb..901517cfd 100644 --- a/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs +++ b/src/Tizen.NUI/src/internal/Common/VisualObjectsContainer.cs @@ -63,27 +63,29 @@ namespace Tizen.NUI.Visuals public Tizen.NUI.BaseComponents.View GetView() { global::System.IntPtr cPtr = Interop.VisualObjectsContainer.GetOwner(SwigCPtr); - - Tizen.NUI.BaseComponents.View ret = null; + if (Interop.RefObject.GetRefObjectPtr(cPtr) == global::System.IntPtr.Zero) { // Visual container don't have owner. Return null. Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); + NDalicPINVOKE.ThrowExceptionIfExists(); } else { - ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Tizen.NUI.BaseComponents.View; + Tizen.NUI.BaseComponents.View ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Tizen.NUI.BaseComponents.View; if (ret != null) { Interop.BaseHandle.DeleteBaseHandle(new global::System.Runtime.InteropServices.HandleRef(this, cPtr)); + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; } else { ret = new Tizen.NUI.BaseComponents.View(cPtr, true); + return ret; } } - NDalicPINVOKE.ThrowExceptionIfExists(); - return ret; + return null; } public int GetContainerRangeType() diff --git a/src/Tizen.NUI/src/internal/Transition/TransitionGroupItem.cs b/src/Tizen.NUI/src/internal/Transition/TransitionGroupItem.cs index fefa1275f..bb4c87927 100644 --- a/src/Tizen.NUI/src/internal/Transition/TransitionGroupItem.cs +++ b/src/Tizen.NUI/src/internal/Transition/TransitionGroupItem.cs @@ -53,7 +53,7 @@ namespace Tizen.NUI transitionItemList = new List(); for (int index = 0; index < transitionList.Count; ++index) { - TimePeriod localTimePeriod = new TimePeriod(transitionList[index].GetTimePeriod().DelayMilliseconds, transitionList[index].GetTimePeriod().DurationMilliseconds); + using TimePeriod localTimePeriod = new TimePeriod(transitionList[index].GetTimePeriod().DelayMilliseconds, transitionList[index].GetTimePeriod().DurationMilliseconds); AlphaFunction localAlphaFunction = transitionList[index].GetAlphaFunction(); if (useGroupTimePeriod) { diff --git a/src/Tizen.NUI/src/public/Application/NUIWidgetComponent.cs b/src/Tizen.NUI/src/public/Application/NUIWidgetComponent.cs index 844dc99a0..a26be15b5 100755 --- a/src/Tizen.NUI/src/public/Application/NUIWidgetComponent.cs +++ b/src/Tizen.NUI/src/public/Application/NUIWidgetComponent.cs @@ -57,8 +57,8 @@ namespace Tizen.NUI instance.GetWindow().Hide(); defaultWindowSet = true; } - - Window = new Window(new Rectangle(0, 0, width, height), false); + using var rect = new Rectangle(0, 0, width, height); + Window = new Window(rect, false); Window.Show(); } NUIWindowProxy = new NUIWindowProxy(Window); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index 5b95edad1..baeb2fbc5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -2351,7 +2351,8 @@ namespace Tizen.NUI.BaseComponents if (_border != value) { _border = new Rectangle(value); - UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(_border)); + using var pv = new PropertyValue(_border); + UpdateImage(NpatchImageVisualProperty.Border, pv); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 1e8fd489a..e84f7a64f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -1167,14 +1167,22 @@ namespace Tizen.NUI.BaseComponents // Update currentStates properties to cachedImagePropertyMap if (currentStates.changed) { - UpdateImage(ImageVisualProperty.LoopCount, new PropertyValue(currentStates.loopCount), false); - UpdateImage(ImageVisualProperty.StopBehavior, new PropertyValue((int)currentStates.stopEndAction), false); - UpdateImage(ImageVisualProperty.LoopingMode, new PropertyValue((int)currentStates.loopMode), false); - UpdateImage(ImageVisualProperty.RedrawInScalingDown, new PropertyValue(currentStates.redrawInScalingDown), false); - UpdateImage(ImageVisualProperty.SynchronousLoading, new PropertyValue(currentStates.synchronousLoading), false); - UpdateImage(ImageVisualProperty.EnableFrameCache, new PropertyValue(currentStates.enableFrameCache), false); - UpdateImage(ImageVisualProperty.NotifyAfterRasterization, new PropertyValue(currentStates.notifyAfterRasterization), false); - UpdateImage(ImageVisualProperty.FrameSpeedFactor, new PropertyValue(currentStates.frameSpeedFactor), false); + using (var pv = new PropertyValue(currentStates.loopCount)) + UpdateImage(ImageVisualProperty.LoopCount, pv, false); + using (var pv = new PropertyValue((int)currentStates.stopEndAction)) + UpdateImage(ImageVisualProperty.StopBehavior, pv, false); + using (var pv = new PropertyValue((int)currentStates.loopMode)) + UpdateImage(ImageVisualProperty.LoopingMode, pv, false); + using (var pv = new PropertyValue(currentStates.redrawInScalingDown)) + UpdateImage(ImageVisualProperty.RedrawInScalingDown, pv, false); + using (var pv = new PropertyValue(currentStates.synchronousLoading)) + UpdateImage(ImageVisualProperty.SynchronousLoading, pv, false); + using (var pv = new PropertyValue(currentStates.enableFrameCache)) + UpdateImage(ImageVisualProperty.EnableFrameCache, pv, false); + using (var pv = new PropertyValue(currentStates.notifyAfterRasterization)) + UpdateImage(ImageVisualProperty.NotifyAfterRasterization, pv, false); + using (var pv = new PropertyValue(currentStates.frameSpeedFactor)) + UpdateImage(ImageVisualProperty.FrameSpeedFactor, pv, false); // Do not cache PlayRange and TotalFrameNumber into cachedImagePropertyMap. // (To keep legacy implements behaviour) diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index aee02eaf1..e085e306c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -5418,17 +5418,21 @@ namespace Tizen.NUI.BaseComponents { ret = new View(Layer.getCPtr(layer).Handle, false); NUILog.Error("This Parent property is deprecated, should do not be used"); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + + if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve()); + return ret; } else { ret = basehandle as View; - } - - Interop.BaseHandle.DeleteBaseHandle(CPtr); - CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + Interop.BaseHandle.DeleteBaseHandle(CPtr); + CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); - if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve()); - return ret; + if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve()); + return ret; + } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index 278f956a5..18f685cea 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -2251,7 +2251,10 @@ namespace Tizen.NUI.BaseComponents int visualType = 0; - map.Find(Visual.Property.Type)?.Get(out visualType); + using (var pv = map.Find(Visual.Property.Type)) + { + pv?.Get(out visualType); + } if (visualType == (int)Visual.Type.Image) { @@ -2261,7 +2264,10 @@ namespace Tizen.NUI.BaseComponents // Background extra data flag is not meanful anymore. backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background; - Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)SwigCPtr, View.Property.BACKGROUND, new PropertyValue(map)); + using (var pv = new PropertyValue(map)) + { + Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.BACKGROUND, pv); + } } private void SetBorderlineColor(Color value) @@ -2302,9 +2308,8 @@ namespace Tizen.NUI.BaseComponents backgroundExtraDataUpdatedFlag &= ~BackgroundExtraDataUpdatedFlag.Background; - var mapValue = new PropertyValue(map); + using var mapValue = new PropertyValue(map); Object.SetProperty(SwigCPtr, Property.BACKGROUND, mapValue); - } private void SetColor(Color value) @@ -2367,7 +2372,8 @@ namespace Tizen.NUI.BaseComponents private void SetShadow(ShadowBase value) { - Tizen.NUI.Object.SetProperty((System.Runtime.InteropServices.HandleRef)SwigCPtr, View.Property.SHADOW, value == null ? new PropertyValue() : value.ToPropertyValue(this)); + using var pv = value == null ? new PropertyValue() : value.ToPropertyValue(this); + Tizen.NUI.Object.SetProperty(SwigCPtr, View.Property.SHADOW, pv); } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs index 8a870c026..002226cfe 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewPublicMethods.cs @@ -499,6 +499,7 @@ namespace Tizen.NUI.BaseComponents { // Register new camera into Registry. ret = new Animatable(cPtr, true); + return ret; } else { @@ -506,9 +507,9 @@ namespace Tizen.NUI.BaseComponents HandleRef handle = new HandleRef(this, cPtr); Interop.Actor.DeleteActor(handle); handle = new HandleRef(null, IntPtr.Zero); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } /// @@ -647,13 +648,14 @@ namespace Tizen.NUI.BaseComponents if (ret != null) { Interop.BaseHandle.DeleteBaseHandle(new HandleRef(this, cPtr)); + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; } else { ret = new Renderable(cPtr, true); + return ret; } - NDalicPINVOKE.ThrowExceptionIfExists(); - return ret; } /// diff --git a/src/Tizen.NUI/src/public/Common/TypeRegistry.cs b/src/Tizen.NUI/src/public/Common/TypeRegistry.cs index 8c40acb2f..8f5ef1ad5 100755 --- a/src/Tizen.NUI/src/public/Common/TypeRegistry.cs +++ b/src/Tizen.NUI/src/public/Common/TypeRegistry.cs @@ -85,14 +85,14 @@ namespace Tizen.NUI global::System.Runtime.InteropServices.HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(dummyObect, cPtr); Interop.BaseHandle.DeleteBaseHandle(CPtr); CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } else { ret = new TypeRegistry(cPtr, true); + return ret; } - - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } [EditorBrowsable(EditorBrowsableState.Never)] @@ -147,14 +147,14 @@ namespace Tizen.NUI global::System.Runtime.InteropServices.HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); Interop.BaseHandle.DeleteBaseHandle(CPtr); CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } else { ret = new Tizen.NUI.TypeInfo(cPtr, true); + return ret; } - - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } internal Tizen.NUI.TypeInfo GetTypeInfo(SWIGTYPE_p_std__type_info registerType) diff --git a/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs b/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs index 6dbe0b47d..5be844e00 100644 --- a/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs +++ b/src/Tizen.NUI/src/public/ParticleSystem/ParticleEmitter.cs @@ -223,12 +223,13 @@ namespace Tizen.NUI.ParticleSystem { set { - var pixelBuffer = ImageLoader.LoadImageFromFile(value); + using var pixelBuffer = ImageLoader.LoadImageFromFile(value); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - Texture tex = new Texture(TextureType.TEXTURE_2D, PixelFormat.RGBA8888, pixelBuffer.GetWidth(), + using Texture tex = new Texture(TextureType.TEXTURE_2D, PixelFormat.RGBA8888, pixelBuffer.GetWidth(), pixelBuffer.GetHeight()); - tex.Upload(pixelBuffer.CreatePixelData()); + using var pd = pixelBuffer.CreatePixelData(); + tex.Upload(pd); Interop.ParticleEmitter.SetTexture(SwigCPtr, tex.SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); diff --git a/src/Tizen.NUI/src/public/Utility/Capture.cs b/src/Tizen.NUI/src/public/Utility/Capture.cs index d74d7a71b..e618ac649 100755 --- a/src/Tizen.NUI/src/public/Utility/Capture.cs +++ b/src/Tizen.NUI/src/public/Utility/Capture.cs @@ -152,7 +152,9 @@ namespace Tizen.NUI if (source is View || source is Layer) { - Interop.Capture.Start4(SwigCPtr, source.SwigCPtr, new Vector2(position.X, position.Y).SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr); + 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); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -196,7 +198,8 @@ namespace Tizen.NUI if (source is View || source is Layer) { - Interop.Capture.Start3(SwigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr, quality); + 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); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -235,7 +238,8 @@ namespace Tizen.NUI if (source is View || source is Layer) { - Interop.Capture.Start1(SwigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path, new Vector4(color.R, color.G, color.B, color.A).SwigCPtr); + 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); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -272,7 +276,8 @@ namespace Tizen.NUI if (source is View || source is Layer) { - Interop.Capture.Start2(SwigCPtr, source.SwigCPtr, new Vector2(size.Width, size.Height).SwigCPtr, path); + using var sizeVector2 = new Vector2(size.Width, size.Height); + Interop.Capture.Start2(SwigCPtr, source.SwigCPtr, sizeVector2.SwigCPtr, path); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -357,13 +362,14 @@ namespace Tizen.NUI if (ret != null) { Interop.BaseHandle.DeleteBaseHandle(new HandleRef(this, cPtr)); + NDalicPINVOKE.ThrowExceptionIfExists(); + return ret; } else { ret = new ImageUrl(cPtr, true); + return ret; } - NDalicPINVOKE.ThrowExceptionIfExists(); - return ret; } /// diff --git a/src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs b/src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs index 12fe5c748..8182f6194 100755 --- a/src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs +++ b/src/Tizen.NUI/src/public/Visuals/AnimatedImageVisual.cs @@ -173,16 +173,16 @@ namespace Tizen.NUI } else { - var urlArray = new PropertyArray(); + using var urlArray = new PropertyArray(); foreach (var url in urls) { - urlArray.Add(new PropertyValue(url)); + var pv = new PropertyValue(url); + using var _ = urlArray.Add(pv); } using (var temp = new PropertyValue(urlArray)) { _outputVisualMap.Add(ImageVisualProperty.URL, temp); } - urlArray.Dispose(); } if (batchSize != null) { diff --git a/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs b/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs index 0ca06449d..23b3697a2 100755 --- a/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualFactory.cs @@ -84,14 +84,14 @@ namespace Tizen.NUI global::System.Runtime.InteropServices.HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(dummyObect, cPtr); Interop.BaseHandle.DeleteBaseHandle(CPtr); CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } else { ret = new VisualFactory(cPtr, true); + return ret; } - - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/Visuals/VisualObject/AnimatedImageVisual.cs b/src/Tizen.NUI/src/public/Visuals/VisualObject/AnimatedImageVisual.cs index ee1dda044..fd1ceb089 100644 --- a/src/Tizen.NUI/src/public/Visuals/VisualObject/AnimatedImageVisual.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualObject/AnimatedImageVisual.cs @@ -296,8 +296,8 @@ namespace Tizen.NUI.Visuals using var urlArray = new PropertyArray(); foreach (var url in resourceUrls) { - using var urlValue = new PropertyValue(url); - urlArray.Add(urlValue); + var urlValue = new PropertyValue(url); + using var _ = urlArray.Add(urlValue); } if (cachedVisualPropertyMap != null) diff --git a/src/Tizen.NUI/src/public/Visuals/VisualObject/BorderVisual.cs b/src/Tizen.NUI/src/public/Visuals/VisualObject/BorderVisual.cs index 2d18cb799..f858b30b9 100644 --- a/src/Tizen.NUI/src/public/Visuals/VisualObject/BorderVisual.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualObject/BorderVisual.cs @@ -60,8 +60,10 @@ namespace Tizen.NUI.Visuals get { Tizen.NUI.Color ret = new Tizen.NUI.Color(); - using var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.BorderVisualProperty.Color); - propertyValue?.Get(ret); + using (var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.BorderVisualProperty.Color)) + { + propertyValue?.Get(ret); + } return ret; } } diff --git a/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs b/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs index c1591efac..3e5e3b1e5 100644 --- a/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs +++ b/src/Tizen.NUI/src/public/Visuals/VisualObject/VisualBase.cs @@ -904,7 +904,8 @@ namespace Tizen.NUI.Visuals // Get type from the property map. internalType = (int)Tizen.NUI.Visual.Type.Invalid; - if (cachedVisualPropertyMap?.Find((int)Tizen.NUI.Visual.Property.Type)?.Get(out internalType) ?? false) + using var pv = cachedVisualPropertyMap?.Find((int)Tizen.NUI.Visual.Property.Type); + if (pv?.Get(out internalType) ?? false) { UpdateVisualPropertyMap(); } diff --git a/src/Tizen.NUI/src/public/Window/Window.cs b/src/Tizen.NUI/src/public/Window/Window.cs index f23983e5d..26e198e15 100755 --- a/src/Tizen.NUI/src/public/Window/Window.cs +++ b/src/Tizen.NUI/src/public/Window/Window.cs @@ -1362,6 +1362,7 @@ namespace Tizen.NUI } Interop.Window.FeedHoverEvent(SwigCPtr, TouchPoint.getCPtr(touchPoint)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + touchPoint.Dispose(); } /// @@ -1645,14 +1646,14 @@ namespace Tizen.NUI HandleRef CPtr = new HandleRef(this, cPtr); Interop.BaseHandle.DeleteBaseHandle(CPtr); CPtr = new HandleRef(null, global::System.IntPtr.Zero); + if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return ret; } else { ret = new RenderTaskList(cPtr, true); + return ret; } - - if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - return ret; } /// diff --git a/src/Tizen.NUI/src/public/Window/WindowEvent.cs b/src/Tizen.NUI/src/public/Window/WindowEvent.cs index a6184995c..60ca5896e 100755 --- a/src/Tizen.NUI/src/public/Window/WindowEvent.cs +++ b/src/Tizen.NUI/src/public/Window/WindowEvent.cs @@ -1939,7 +1939,10 @@ namespace Tizen.NUI for (int i = 0; i < size; i++) { string option = "none"; - tmp.GetElementAt((uint)i).Get(out option); + using (var pv = tmp.GetElementAt((uint)i)) + { + pv.Get(out option); + } tmpList.Add(option); } -- 2.34.1