[NUI] Add defence code for Window.VisibilityChanged event
authordongsug.song <dongsug.song@samsung.com>
Fri, 14 Apr 2023 06:53:53 +0000 (15:53 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 19 Apr 2023 02:27:12 +0000 (11:27 +0900)
src/Tizen.NUI/src/public/Window/WindowEvent.cs

index 86e8959..fcb5eae 100755 (executable)
@@ -1270,6 +1270,16 @@ namespace Tizen.NUI
         {
             add
             {
+                // This is to defend against problems in the operation of unsubscribing the VisibilityChanged event of the sub window within the handler,
+                // where the sub window is disabled and the View RemovedFromWindow event occurs.
+                // The problem seems to have occurred because the native window object itself is invalid 
+                // when trying to obtain the window native signal because the sub window is in the Dispose state.
+                if (disposed)
+                {
+                    Tizen.Log.Error("NUI", "[ERR] This Window object has already been destroyed, but VisibilityChanged event is added or removed!");
+                    return;
+                }
+
                 if (VisibilityChangedEventHandler == null)
                 {
                     VisibilityChangedEventCallback = OnVisibilityChanged;
@@ -1280,6 +1290,16 @@ namespace Tizen.NUI
             }
             remove
             {
+                // This is to defend against problems in the operation of unsubscribing the VisibilityChanged event of the sub window within the handler,
+                // where the sub window is disabled and the View RemovedFromWindow event occurs.
+                // The problem seems to have occurred because the native window object itself is invalid 
+                // when trying to obtain the window native signal because the sub window is in the Dispose state.
+                if (disposed)
+                {
+                    Tizen.Log.Error("NUI", "[ERR] This Window object has already been destroyed, but VisibilityChanged event is added or removed!");
+                    return;
+                }
+
                 VisibilityChangedEventHandler -= value;
                 if (VisibilityChangedEventHandler == null && VisibilityChangedEventCallback != null)
                 {