[NUI] Fix CA2000 warning for Window
authorzhouleonlei <zhouleon.lei@samsung.com>
Tue, 22 Dec 2020 06:24:01 +0000 (14:24 +0800)
committerhuiyueun <35286162+huiyueun@users.noreply.github.com>
Mon, 11 Jan 2021 05:49:43 +0000 (14:49 +0900)
src/Tizen.NUI/src/public/Window.cs
src/Tizen.NUI/src/public/WindowEvent.cs

index c586e6ec09b8678e3b5c640ea48fc604d9a214e3..36cc3a3ba667a2bc399e8c374b1802d162eccf17 100755 (executable)
@@ -423,6 +423,7 @@ namespace Tizen.NUI
                 Position2D position = GetPosition();
                 Size2D size = GetSize();
                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
+                position.Dispose();
                 return ret;
             }
             set
@@ -1165,11 +1166,14 @@ namespace Tizen.NUI
             {
                 for (int i = 0; i < orientations.Count; i++)
                 {
-                    orientationArray.PushBack(new PropertyValue((int)orientations[i]));
+                    PropertyValue value = new PropertyValue((int)orientations[i]);
+                    orientationArray.PushBack(value);
+                    value.Dispose();
                 }
             }
 
             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray));
+            orientationArray.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
@@ -1222,6 +1226,7 @@ namespace Tizen.NUI
         {
             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), false);
             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
+            val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -1309,9 +1314,8 @@ namespace Tizen.NUI
             }
             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
-
+            val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-
             // Resetting Window size should request a relayout of the tree.
         }
 
@@ -1319,7 +1323,7 @@ namespace Tizen.NUI
         {
             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), false);
             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
-
+            val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
@@ -1332,7 +1336,7 @@ namespace Tizen.NUI
             }
             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
             Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
-
+            val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             // Setting Position of the window should request a relayout of the tree.
         }
@@ -1341,7 +1345,7 @@ namespace Tizen.NUI
         {
             var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
             Position2D ret = new Position2D(val.GetX(), val.GetY());
-
+            val.Dispose();
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
         }
index fd9686bd3dedfe6cf121e7f13bc5ac19d4380e4b..43c55147366ceb32bd031796bfa3f274236c1931 100755 (executable)
@@ -46,6 +46,18 @@ namespace Tizen.NUI
         private WindowTransitionEffectSignal transitionEffectSignal;
         private KeyboardRepeatSettingsChangedEventCallbackType keyboardRepeatSettingsChangedEventCallback;
         private KeyboardRepeatSettingsChangedSignal keyboardRepeatSettingsChangedSignal;
+        private WindowFocusSignalType windowFocusChangedSignal;
+        private WindowFocusSignalType windowFocusChangedSignal2;
+        private TouchDataSignal touchDataSignal;
+        private TouchSignal touchSignal;
+        private WheelSignal wheelSignal;
+        private StageWheelSignal stageWheelSignal;
+        private KeyEventSignal keyEventSignal;
+        private VoidSignal sceneCreatedSignal;
+        private ResizeSignal resizeSignal;
+        private VoidSignal eventProcessingFinishedSignal;
+        private VoidSignal contextLostSignal;
+        private VoidSignal contextRegainedSignal;
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained);
@@ -73,7 +85,8 @@ namespace Tizen.NUI
                 if (_windowFocusChangedEventHandler == null)
                 {
                     _windowFocusChangedEventCallback = OnWindowFocusedChanged;
-                    WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
+                    windowFocusChangedSignal = WindowFocusChangedSignal();
+                    windowFocusChangedSignal?.Connect(_windowFocusChangedEventCallback);
                 }
 
                 _windowFocusChangedEventHandler += value;
@@ -82,9 +95,9 @@ namespace Tizen.NUI
             {
                 _windowFocusChangedEventHandler -= value;
 
-                if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
+                if (_windowFocusChangedEventHandler == null && windowFocusChangedSignal?.Empty() == false && _windowFocusChangedEventCallback != null)
                 {
-                    WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
+                    windowFocusChangedSignal?.Disconnect(_windowFocusChangedEventCallback);
                 }
             }
         }
@@ -103,16 +116,18 @@ namespace Tizen.NUI
                 if (_rootLayerTouchDataEventHandler == null)
                 {
                     _rootLayerTouchDataCallback = OnWindowTouch;
-                    this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
+                    touchDataSignal = this.TouchDataSignal();
+                    touchDataSignal?.Connect(_rootLayerTouchDataCallback);
                 }
                 _rootLayerTouchDataEventHandler += value;
             }
             remove
             {
                 _rootLayerTouchDataEventHandler -= value;
-                if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false && _rootLayerTouchDataCallback != null)
+                touchSignal = TouchSignal();
+                if (_rootLayerTouchDataEventHandler == null && touchSignal?.Empty() == false && _rootLayerTouchDataCallback != null)
                 {
-                    this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
+                    touchDataSignal?.Disconnect(_rootLayerTouchDataCallback);
                 }
             }
         }
@@ -128,29 +143,31 @@ namespace Tizen.NUI
                 if (_stageWheelHandler == null)
                 {
                     _wheelEventCallback = OnStageWheel;
-                    WheelEventSignal().Connect(_wheelEventCallback);
+                    wheelSignal = WheelEventSignal();
+                    wheelSignal?.Connect(_wheelEventCallback);
                 }
                 _stageWheelHandler += value;
 
                 if (DetentEventHandler == null)
                 {
                     DetentEventCallback = OnDetentEvent;
-                    StageWheelEventSignal().Connect(DetentEventCallback);
+                    stageWheelSignal = StageWheelEventSignal();
+                    stageWheelSignal?.Connect(DetentEventCallback);
                 }
                 DetentEventHandler += value;
             }
             remove
             {
                 _stageWheelHandler -= value;
-                if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
+                if (_stageWheelHandler == null && wheelSignal?.Empty() == false)
                 {
-                    WheelEventSignal().Disconnect(_wheelEventCallback);
+                    wheelSignal?.Disconnect(_wheelEventCallback);
                 }
 
                 DetentEventHandler -= value;
-                if (DetentEventHandler == null && StageWheelEventSignal().Empty() == false)
+                if (DetentEventHandler == null && stageWheelSignal?.Empty() == false)
                 {
-                    StageWheelEventSignal().Disconnect(DetentEventCallback);
+                    stageWheelSignal?.Disconnect(DetentEventCallback);
                 }
             }
         }
@@ -166,16 +183,17 @@ namespace Tizen.NUI
                 if (_stageKeyHandler == null)
                 {
                     _stageKeyCallbackDelegate = OnStageKey;
-                    KeyEventSignal().Connect(_stageKeyCallbackDelegate);
+                    keyEventSignal = KeyEventSignal();
+                    keyEventSignal?.Connect(_stageKeyCallbackDelegate);
                 }
                 _stageKeyHandler += value;
             }
             remove
             {
                 _stageKeyHandler -= value;
-                if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
+                if (_stageKeyHandler == null && keyEventSignal?.Empty() == false)
                 {
-                    KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
+                    keyEventSignal?.Disconnect(_stageKeyCallbackDelegate);
                 }
             }
         }
@@ -191,7 +209,8 @@ namespace Tizen.NUI
                 if (_windowResizeEventHandler == null)
                 {
                     _windowResizeEventCallback = OnResized;
-                    ResizeSignal().Connect(_windowResizeEventCallback);
+                    resizeSignal = ResizeSignal();
+                    resizeSignal?.Connect(_windowResizeEventCallback);
                 }
 
                 _windowResizeEventHandler += value;
@@ -200,9 +219,9 @@ namespace Tizen.NUI
             {
                 _windowResizeEventHandler -= value;
 
-                if (_windowResizeEventHandler == null && ResizeSignal().Empty() == false && _windowResizeEventCallback != null)
+                if (_windowResizeEventHandler == null && resizeSignal?.Empty() == false && _windowResizeEventCallback != null)
                 {
-                    ResizeSignal().Disconnect(_windowResizeEventCallback);
+                    resizeSignal?.Disconnect(_windowResizeEventCallback);
                 }
             }
         }
@@ -225,7 +244,8 @@ namespace Tizen.NUI
                 if (_windowFocusChangedEventHandler2 == null)
                 {
                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
-                    WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
+                    windowFocusChangedSignal2 = WindowFocusChangedSignal();
+                    windowFocusChangedSignal2?.Connect(_windowFocusChangedEventCallback2);
                 }
 
                 _windowFocusChangedEventHandler2 += value;
@@ -234,9 +254,9 @@ namespace Tizen.NUI
             {
                 _windowFocusChangedEventHandler2 -= value;
 
-                if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
+                if (_windowFocusChangedEventHandler2 == null && windowFocusChangedSignal2?.Empty() == false && _windowFocusChangedEventCallback2 != null)
                 {
-                    WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
+                    windowFocusChangedSignal2?.Disconnect(_windowFocusChangedEventCallback2);
                 }
             }
         }
@@ -320,7 +340,8 @@ namespace Tizen.NUI
                 if (_stageEventProcessingFinishedEventHandler == null)
                 {
                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
-                    EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
+                    eventProcessingFinishedSignal = EventProcessingFinishedSignal();
+                    eventProcessingFinishedSignal?.Connect(_stageEventProcessingFinishedEventCallbackDelegate);
                 }
                 _stageEventProcessingFinishedEventHandler += value;
 
@@ -328,9 +349,9 @@ namespace Tizen.NUI
             remove
             {
                 _stageEventProcessingFinishedEventHandler -= value;
-                if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
+                if (_stageEventProcessingFinishedEventHandler == null && eventProcessingFinishedSignal?.Empty() == false)
                 {
-                    EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
+                    eventProcessingFinishedSignal?.Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
                 }
             }
         }
@@ -342,16 +363,17 @@ namespace Tizen.NUI
                 if (_stageContextLostEventHandler == null)
                 {
                     _stageContextLostEventCallbackDelegate = OnContextLost;
-                    ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
+                    contextLostSignal = ContextLostSignal();
+                    contextLostSignal?.Connect(_stageContextLostEventCallbackDelegate);
                 }
                 _stageContextLostEventHandler += value;
             }
             remove
             {
                 _stageContextLostEventHandler -= value;
-                if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
+                if (_stageContextLostEventHandler == null && contextLostSignal?.Empty() == false)
                 {
-                    ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
+                    contextLostSignal?.Disconnect(_stageContextLostEventCallbackDelegate);
                 }
             }
         }
@@ -363,16 +385,17 @@ namespace Tizen.NUI
                 if (_stageContextRegainedEventHandler == null)
                 {
                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
-                    ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
+                    contextRegainedSignal = ContextRegainedSignal();
+                    contextRegainedSignal?.Connect(_stageContextRegainedEventCallbackDelegate);
                 }
                 _stageContextRegainedEventHandler += value;
             }
             remove
             {
                 _stageContextRegainedEventHandler -= value;
-                if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
+                if (_stageContextRegainedEventHandler == null && contextRegainedSignal?.Empty() == false)
                 {
-                    this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
+                    contextRegainedSignal?.Disconnect(_stageContextRegainedEventCallbackDelegate);
                 }
             }
         }
@@ -384,16 +407,17 @@ namespace Tizen.NUI
                 if (_stageSceneCreatedEventHandler == null)
                 {
                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
-                    SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
+                    sceneCreatedSignal = SceneCreatedSignal();
+                    sceneCreatedSignal?.Connect(_stageSceneCreatedEventCallbackDelegate);
                 }
                 _stageSceneCreatedEventHandler += value;
             }
             remove
             {
                 _stageSceneCreatedEventHandler -= value;
-                if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
+                if (_stageSceneCreatedEventHandler == null && sceneCreatedSignal?.Empty() == false)
                 {
-                    SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
+                    sceneCreatedSignal?.Disconnect(_stageSceneCreatedEventCallbackDelegate);
                 }
             }
         }
@@ -484,57 +508,57 @@ namespace Tizen.NUI
         {
             if (_windowFocusChangedEventCallback != null)
             {
-                WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
+                windowFocusChangedSignal?.Disconnect(_windowFocusChangedEventCallback);
             }
 
             if (_rootLayerTouchDataCallback != null)
             {
-                TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
+                touchDataSignal?.Disconnect(_rootLayerTouchDataCallback);
             }
 
             if (_wheelEventCallback != null)
             {
-                WheelEventSignal().Disconnect(_wheelEventCallback);
+                wheelSignal?.Disconnect(_wheelEventCallback);
             }
 
             if (DetentEventCallback != null)
             {
-                StageWheelEventSignal().Disconnect(DetentEventCallback);
+                stageWheelSignal?.Disconnect(DetentEventCallback);
             }
 
             if (_stageKeyCallbackDelegate != null)
             {
-                KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
+                keyEventSignal?.Disconnect(_stageKeyCallbackDelegate);
             }
 
             if (_stageEventProcessingFinishedEventCallbackDelegate != null)
             {
-                EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
+                eventProcessingFinishedSignal?.Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
             }
 
             if (_stageContextLostEventCallbackDelegate != null)
             {
-                ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
+                contextLostSignal?.Disconnect(_stageContextLostEventCallbackDelegate);
             }
 
             if (_stageContextRegainedEventCallbackDelegate != null)
             {
-                ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
+                contextRegainedSignal?.Disconnect(_stageContextRegainedEventCallbackDelegate);
             }
 
             if (_stageSceneCreatedEventCallbackDelegate != null)
             {
-                SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
+                sceneCreatedSignal?.Disconnect(_stageSceneCreatedEventCallbackDelegate);
             }
 
             if (_windowResizeEventCallback != null)
             {
-                ResizeSignal().Disconnect(_windowResizeEventCallback);
+                resizeSignal?.Disconnect(_windowResizeEventCallback);
             }
 
             if (_windowFocusChangedEventCallback2 != null)
             {
-                WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
+                windowFocusChangedSignal2?.Disconnect(_windowFocusChangedEventCallback2); 
             }
 
             if (transitionEffectSignal != null)