[NUI] Add dispose checking in just a few methods of Timer class (#1338)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 22 Jan 2020 23:45:22 +0000 (08:45 +0900)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Wed, 22 Jan 2020 23:45:22 +0000 (08:45 +0900)
src/Tizen.NUI/src/public/Timer.cs

index 7e7b761..6be8ba4 100755 (executable)
@@ -204,6 +204,12 @@ namespace Tizen.NUI
                 }
             }
 
+            if (swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            {
+                NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!");
+                return;
+            }
+
             played = true;
             Interop.Timer.Timer_Start(swigCPtr);
 
@@ -229,6 +235,12 @@ namespace Tizen.NUI
                 }
             }
 
+            if (swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            {
+                NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!");
+                return;
+            }
+
             played = false;
             Interop.Timer.Timer_Stop(swigCPtr);
 
@@ -254,6 +266,12 @@ namespace Tizen.NUI
                 }
             }
 
+            if (swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            {
+                NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!");
+                return false;
+            }
+
             bool ret = Interop.Timer.Timer_IsRunning(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
@@ -273,6 +291,12 @@ namespace Tizen.NUI
         {
             NUILog.Debug($"(0x{swigCPtr.Handle:X})SetInterval({milliSec})");
 
+            if (swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            {
+                NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!");
+                return;
+            }
+
             played = true;
 
             Interop.Timer.Timer_SetInterval(swigCPtr, milliSec);
@@ -281,6 +305,12 @@ namespace Tizen.NUI
 
         internal uint GetInterval()
         {
+            if(swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            {
+                NUILog.Error("[ERR] already disposed! can not get this done! just return here! please make sure that the handle gets free when using explicit Dispose()! For example, timer.Dispose(); timer = null; this must be done!");
+                return 0;
+            }
+
             uint ret = Interop.Timer.Timer_GetInterval(swigCPtr);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;