From 971eaed187d224544eef052263bf3978c6ac27d4 Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Tue, 1 Nov 2022 13:55:46 +0900 Subject: [PATCH] [NUI] Add native handle null check in Uint16Pair --- src/Tizen.NUI/src/internal/Common/Uint16Pair.cs | 68 +++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/src/Tizen.NUI/src/internal/Common/Uint16Pair.cs b/src/Tizen.NUI/src/internal/Common/Uint16Pair.cs index b3c93e3..1a9cdbf 100755 --- a/src/Tizen.NUI/src/internal/Common/Uint16Pair.cs +++ b/src/Tizen.NUI/src/internal/Common/Uint16Pair.cs @@ -15,8 +15,8 @@ * */ -using System; -using System.ComponentModel; +using global::System; +using global::System.Runtime.InteropServices; namespace Tizen.NUI { @@ -31,12 +31,19 @@ namespace Tizen.NUI internal class Uint16Pair : Disposable { - internal Uint16Pair(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) + internal Uint16Pair(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } - protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + protected override void ReleaseSwigCPtr(HandleRef swigCPtr) { + if (swigCPtr.Handle == IntPtr.Zero) + { + //Log.Fatal("NUI", "Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + //Log.Fatal("NUI", "Error! just return here! this can cause unknown error or crash in next step"); + //return false; + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Interop.Uint16Pair.DeleteUint16Pair(swigCPtr); } @@ -95,6 +102,10 @@ namespace Tizen.NUI /// The x dimension to be stored in this 2-tuple. public void SetWidth(ushort width) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Interop.Uint16Pair.SetWidth(SwigCPtr, width); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -107,6 +118,10 @@ namespace Tizen.NUI /// public ushort GetWidth() { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } ushort ret = Interop.Uint16Pair.GetWidth(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -118,6 +133,10 @@ namespace Tizen.NUI /// The y dimension to be stored in this 2-tuple. public void SetHeight(ushort height) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Interop.Uint16Pair.SetHeight(SwigCPtr, height); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -130,6 +149,10 @@ namespace Tizen.NUI /// public ushort GetHeight() { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } ushort ret = Interop.Uint16Pair.GetHeight(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -141,6 +164,10 @@ namespace Tizen.NUI /// The x dimension to be stored in this 2-tuple. public void SetX(ushort x) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Interop.Uint16Pair.SetX(SwigCPtr, x); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -153,6 +180,10 @@ namespace Tizen.NUI /// public ushort GetX() { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } ushort ret = Interop.Uint16Pair.GetX(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -164,6 +195,10 @@ namespace Tizen.NUI /// The y dimension to be stored in this 2-tuple. public void SetY(ushort y) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Interop.Uint16Pair.SetY(SwigCPtr, y); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } @@ -176,6 +211,10 @@ namespace Tizen.NUI /// public ushort GetY() { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } ushort ret = Interop.Uint16Pair.GetY(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -188,6 +227,10 @@ namespace Tizen.NUI /// The created object. public Uint16Pair Assign(Uint16Pair rhs) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } Uint16Pair ret = new Uint16Pair(Interop.Uint16Pair.Assign(SwigCPtr, Uint16Pair.getCPtr(rhs)), false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -195,6 +238,10 @@ namespace Tizen.NUI private bool EqualTo(Uint16Pair rhs) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } bool ret = Interop.Uint16Pair.EqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -202,6 +249,10 @@ namespace Tizen.NUI private bool NotEqualTo(Uint16Pair rhs) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } bool ret = Interop.Uint16Pair.NotEqualTo(SwigCPtr, Uint16Pair.getCPtr(rhs)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -209,6 +260,10 @@ namespace Tizen.NUI private bool LessThan(Uint16Pair rhs) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } bool ret = Interop.Uint16Pair.LessThan(SwigCPtr, Uint16Pair.getCPtr(rhs)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; @@ -216,9 +271,14 @@ namespace Tizen.NUI private bool GreaterThan(Uint16Pair rhs) { + if (SwigCPtr.Handle == IntPtr.Zero) + { + throw new InvalidOperationException("Error! NUI.Uint16Pair's native DALi object is already disposed! OR the native DALi object handle of NUI.Uint16Pair's became null by unknown reason!"); + } bool ret = Interop.Uint16Pair.GreaterThan(SwigCPtr, Uint16Pair.getCPtr(rhs)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } + } } -- 2.7.4