[NUI] Add implicit dispose check
authordongsug.song <dongsug.song@samsung.com>
Fri, 2 Dec 2022 11:53:12 +0000 (20:53 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Fri, 2 Dec 2022 12:03:03 +0000 (21:03 +0900)
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/BaseHandle.cs

index 3a50044..4c15cca 100755 (executable)
@@ -919,6 +919,12 @@ namespace Tizen.NUI.BaseComponents
         // Callback for View TouchSignal
         private bool OnTouch(IntPtr view, IntPtr touchData)
         {
+            if (IsDisposeQueued)
+            {
+                NUILog.Error("implicit disposed(unreachable)! just return here!");
+                return true;
+            }
+            
             if (touchData == global::System.IntPtr.Zero)
             {
                 NUILog.Error("touchData should not be null!");
index a6f142a..77113d1 100755 (executable)
@@ -1131,10 +1131,8 @@ namespace Tizen.NUI.BaseComponents
             //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 (this != null)
-            {
-                DisConnectFromSignals();
-            }
+            
+            DisConnectFromSignals();
 
             foreach (View view in Children)
             {
@@ -1404,7 +1402,6 @@ namespace Tizen.NUI.BaseComponents
         {
             SizeModeFactor = new Vector3(x, y, z);
         }
-
         private void UpdateShadowCornerRadius(float value)
         {
             // TODO Update corner radius property only whe DALi supports visual property update.
index a7d6084..5cbf668 100755 (executable)
@@ -439,6 +439,11 @@ namespace Tizen.NUI
 
         internal void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
         {
+            if (isDisposeQueued)
+            {
+                NUILog.Error("implicit disposed(unreachable)! just return here!");
+                return;
+            }
             PropertySet?.Invoke(this, new PropertyChangedEventArgs(propertyName));
         }
 
@@ -453,6 +458,8 @@ namespace Tizen.NUI
                 return;
             }
 
+            PropertySet = null;
+            
             if (type == DisposeTypes.Explicit)
             {
                 //Called by User
@@ -471,7 +478,7 @@ namespace Tizen.NUI
                 Registry.Unregister(this);
             }
 
-            if(swigCPtr.Handle != IntPtr.Zero)
+            if (swigCPtr.Handle != IntPtr.Zero)
             {
                 if (swigCMemOwn)
                 {
@@ -528,6 +535,8 @@ namespace Tizen.NUI
         /// <remarks>Hidden API: Only for inhouse or developing usage. The behavior and interface can be changed anytime.</remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected internal bool Disposed => disposed;
+
+        protected internal bool IsDisposeQueued => isDisposeQueued;
     }
 
 }