From 0a7c57d6c78d89eccb08c3ee1fb63df604cbec8d Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Thu, 21 Dec 2017 11:53:23 +0900 Subject: [PATCH] [NUI] fix TCT crash issue Change-Id: Ia21049ab623b7bea0ed4038db95b64cb09e71323 Signed-off-by: dongsug.song --- src/Tizen.NUI/src/public/Animation.cs | 22 ++++++++++++++++------ src/Tizen.NUI/src/public/Timer.cs | 25 +++++++++++-------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Tizen.NUI/src/public/Animation.cs b/src/Tizen.NUI/src/public/Animation.cs index aef2822..75db7f9 100755 --- a/src/Tizen.NUI/src/public/Animation.cs +++ b/src/Tizen.NUI/src/public/Animation.cs @@ -47,6 +47,14 @@ namespace Tizen.NUI return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; } + ~Animation() + { + if (_animationFinishedEventCallback != null) + { + _finishedSignal?.Disconnect(_finishedCallbackOfNative); + } + } + /// /// To make animation instance be disposed. /// @@ -55,12 +63,11 @@ namespace Tizen.NUI { if (_animationFinishedEventCallback != null) { - FinishedSignal().Disconnect(_finishedCallbackOfNative); + _finishedSignal?.Disconnect(_finishedCallbackOfNative); } if (_animationProgressReachedEventCallback != null) { - ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback); } @@ -68,6 +75,7 @@ namespace Tizen.NUI { return; } + if(type == DisposeTypes.Explicit) { //Called by User @@ -84,7 +92,7 @@ namespace Tizen.NUI { this.Clear(); this.Reset(); - NUILog.Error("Now Animation is playing! Clear and Reset here!"); + NUILog.Error("Animation().Clear & Reset here!"); //throw new System.InvalidOperationException("Animation Instance should not be disposed until getting Finished event. Should be a global variable"); } @@ -125,6 +133,7 @@ namespace Tizen.NUI private event EventHandler _animationFinishedEventHandler; private System.IntPtr _finishedCallbackOfNative; + private AnimationSignal _finishedSignal; /** * @brief Event for the finished signal which can be used to subscribe or unsubscribe the event handler. @@ -137,7 +146,8 @@ namespace Tizen.NUI { if (_animationFinishedEventHandler == null && disposed == false) { - FinishedSignal().Connect(_finishedCallbackOfNative); + _finishedSignal = FinishedSignal(); + _finishedSignal?.Connect(_finishedCallbackOfNative); } _animationFinishedEventHandler += value; } @@ -145,9 +155,9 @@ namespace Tizen.NUI { _animationFinishedEventHandler -= value; - if (_animationFinishedEventHandler == null && FinishedSignal().Empty() == false) + if (_animationFinishedEventHandler == null && _finishedSignal?.Empty() == false) { - FinishedSignal().Disconnect(_finishedCallbackOfNative); + _finishedSignal?.Disconnect(_finishedCallbackOfNative); } } } diff --git a/src/Tizen.NUI/src/public/Timer.cs b/src/Tizen.NUI/src/public/Timer.cs index 3ca9ff4..7d1824b 100755 --- a/src/Tizen.NUI/src/public/Timer.cs +++ b/src/Tizen.NUI/src/public/Timer.cs @@ -44,13 +44,14 @@ namespace Tizen.NUI _timerTickCallbackDelegate = OnTick; _timerTickCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(_timerTickCallbackDelegate); - - NUILog.Debug($"(0x{swigCPtr.Handle:X})Timer() contructor!"); } ~Timer() { - NUILog.Debug($"(0x{swigCPtr.Handle:X})Timer() distructor!, disposed={disposed}"); + if (_timerTickCallbackDelegate != null) + { + _timerSignal?.Disconnect(_timerTickCallbackOfNative); + } } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Timer obj) @@ -64,11 +65,9 @@ namespace Tizen.NUI /// 3 protected override void Dispose(DisposeTypes type) { - NUILog.Debug($"(0x{swigCPtr.Handle:X}) Timer.Dispose(type={type}, disposed={disposed})"); - if (_timerTickCallbackDelegate != null) { - TickSignal().Disconnect(_timerTickCallbackOfNative); + _timerSignal?.Disconnect(_timerTickCallbackOfNative); } if (disposed) @@ -116,6 +115,7 @@ namespace Tizen.NUI private TickCallbackDelegate _timerTickCallbackDelegate; private System.IntPtr _timerTickCallbackOfNative; + private TimerSignalType _timerSignal; /// /// @brief Event for the ticked signal, which can be used to subscribe or unsubscribe the event handler @@ -128,16 +128,17 @@ namespace Tizen.NUI { if (_timerTickEventHandler == null && disposed == false) { - TickSignal().Connect(_timerTickCallbackOfNative); + _timerSignal = TickSignal(); + _timerSignal?.Connect(_timerTickCallbackOfNative); } _timerTickEventHandler += value; } remove { _timerTickEventHandler -= value; - if (_timerTickEventHandler == null && TickSignal().Empty() == false) + if (_timerTickEventHandler == null && _timerSignal?.Empty() == false) { - TickSignal().Disconnect(_timerTickCallbackOfNative); + _timerSignal?.Disconnect(_timerTickCallbackOfNative); } } } @@ -148,7 +149,7 @@ namespace Tizen.NUI if (played == false) { - Tizen.Log.Fatal("NUI", $"(0x{swigCPtr.Handle:X}) OnTick() is called even played is false!"); + Tizen.Log.Fatal("NUI", $"OnTick() is called even played is false!"); //throw new System.InvalidOperationException($"OnTick() excpetion!"); } @@ -169,8 +170,6 @@ namespace Tizen.NUI public Timer(uint milliSec) : this(NDalicPINVOKE.Timer_New(milliSec), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); - - NUILog.Debug($"(0x{swigCPtr.Handle:X}) Timer({milliSec}) Constructor!"); } internal Timer(Timer timer) : this(NDalicPINVOKE.new_Timer__SWIG_1(Timer.getCPtr(timer)), true) { @@ -228,8 +227,6 @@ namespace Tizen.NUI /// MilliSec interval in milliseconds. internal void SetInterval(uint milliSec) { - NUILog.Debug($"(0x{swigCPtr.Handle:X})SetInterval({milliSec})"); - played = true; NDalicPINVOKE.Timer_SetInterval(swigCPtr, milliSec); -- 2.7.4