From 35eb09a0ce6adc7516dc7a93ea602d91aeba38a0 Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Thu, 19 Jan 2023 09:37:04 +0900 Subject: [PATCH] [NUI] fix testhub crash issue --- .../src/public/Events/PinchGestureDetector.cs | 38 +++++++++++++++++++--- .../src/public/Events/RotationGestureDetector.cs | 38 +++++++++++++++++++--- .../src/public/Events/TapGestureDetector.cs | 38 +++++++++++++++++++--- 3 files changed, 102 insertions(+), 12 deletions(-) diff --git a/src/Tizen.NUI/src/public/Events/PinchGestureDetector.cs b/src/Tizen.NUI/src/public/Events/PinchGestureDetector.cs index caa56a4..7b779ba 100755 --- a/src/Tizen.NUI/src/public/Events/PinchGestureDetector.cs +++ b/src/Tizen.NUI/src/public/Events/PinchGestureDetector.cs @@ -117,15 +117,45 @@ namespace Tizen.NUI return ret; } - /// This will not be public opened. + /// + /// override it to clean-up your own resources. + /// + /// [EditorBrowsable(EditorBrowsableState.Never)] - protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + protected override void Dispose(DisposeTypes type) { - if (detectedCallback != null) + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (HasBody()) { - DetectedSignal().Disconnect(detectedCallback); + if (detectedCallback != null) + { + using PinchGestureDetectedSignal signal = new PinchGestureDetectedSignal(Interop.PinchGesture.PinchGestureDetectorDetectedSignal(GetBaseHandleCPtrHandleRef), false); + signal?.Disconnect(detectedCallback); + detectedCallback = null; + } } + base.Dispose(type); + } + /// This will not be public opened. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { Interop.PinchGesture.DeletePinchGestureDetector(swigCPtr); } diff --git a/src/Tizen.NUI/src/public/Events/RotationGestureDetector.cs b/src/Tizen.NUI/src/public/Events/RotationGestureDetector.cs index c48ff10..b7fad1c 100755 --- a/src/Tizen.NUI/src/public/Events/RotationGestureDetector.cs +++ b/src/Tizen.NUI/src/public/Events/RotationGestureDetector.cs @@ -117,15 +117,45 @@ namespace Tizen.NUI return ret; } - /// This will not be public opened. + /// + /// override it to clean-up your own resources. + /// + /// [EditorBrowsable(EditorBrowsableState.Never)] - protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + protected override void Dispose(DisposeTypes type) { - if (detectedCallback != null) + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + } + + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (HasBody()) { - DetectedSignal().Disconnect(detectedCallback); + if (detectedCallback != null) + { + using RotationGestureDetectedSignal signal = new RotationGestureDetectedSignal(Interop.RotationGesture.RotationGestureDetectorDetectedSignal(GetBaseHandleCPtrHandleRef), false); + signal?.Disconnect(detectedCallback); + detectedCallback = null; + } } + base.Dispose(type); + } + /// This will not be public opened. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { Interop.RotationGesture.DeleteRotationGestureDetector(swigCPtr); } diff --git a/src/Tizen.NUI/src/public/Events/TapGestureDetector.cs b/src/Tizen.NUI/src/public/Events/TapGestureDetector.cs index 89ab9d7..0cfa62b 100755 --- a/src/Tizen.NUI/src/public/Events/TapGestureDetector.cs +++ b/src/Tizen.NUI/src/public/Events/TapGestureDetector.cs @@ -181,15 +181,45 @@ namespace Tizen.NUI return ret; } - /// This will not be public opened. + /// + /// override it to clean-up your own resources. + /// + /// [EditorBrowsable(EditorBrowsableState.Never)] - protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + protected override void Dispose(DisposeTypes type) { - if (_detectedCallback != null) + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) { - DetectedSignal().Disconnect(_detectedCallback); + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. } + //Release your own unmanaged resources here. + //You should not access any managed member here except static instance. + //because the execution order of Finalizes is non-deterministic. + + if (HasBody()) + { + if (_detectedCallback != null) + { + using TapGestureDetectedSignal signal = new TapGestureDetectedSignal(Interop.TapGestureDetector.DetectedSignal(GetBaseHandleCPtrHandleRef), false); + signal?.Disconnect(_detectedCallback); + _detectedCallback = null; + } + } + base.Dispose(type); + } + + /// This will not be public opened. + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) + { Interop.TapGestureDetector.DeleteTapGestureDetector(swigCPtr); } -- 2.7.4