Fixed crash issue by disconnecting from native signals when managed object is being...
authorUmar <m.umar@partner.samsung.com>
Wed, 2 Aug 2017 13:18:48 +0000 (14:18 +0100)
committerUmar <m.umar@partner.samsung.com>
Wed, 2 Aug 2017 15:33:11 +0000 (16:33 +0100)
Change-Id: Iad0855e70830c338b33e475a60a1694d35cdb388

21 files changed:
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/TouchPoint.cs
src/Tizen.NUI/src/internal/ViewWrapperImpl.cs
src/Tizen.NUI/src/public/Animation.cs
src/Tizen.NUI/src/public/BaseComponents/Scrollable.cs
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/VideoView.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/FocusManager.cs
src/Tizen.NUI/src/public/ImfManager.cs
src/Tizen.NUI/src/public/StyleManager.cs
src/Tizen.NUI/src/public/TTSPlayer.cs
src/Tizen.NUI/src/public/Timer.cs
src/Tizen.NUI/src/public/UIComponents/Button.cs
src/Tizen.NUI/src/public/UIComponents/Popup.cs
src/Tizen.NUI/src/public/UIComponents/ProgressBar.cs
src/Tizen.NUI/src/public/UIComponents/ScrollBar.cs
src/Tizen.NUI/src/public/UIComponents/ScrollView.cs
src/Tizen.NUI/src/public/UIComponents/Slider.cs
src/Tizen.NUI/src/public/Window.cs

index ee8be82..07f73ba 100755 (executable)
@@ -346,6 +346,61 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_applicationInitEventCallbackDelegate != null)
+            {
+                this.InitSignal().Disconnect(_applicationInitEventCallbackDelegate);
+            }
+
+            if (_applicationTerminateEventCallbackDelegate != null)
+            {
+                this.TerminateSignal().Disconnect(_applicationTerminateEventCallbackDelegate);
+            }
+
+            if (_applicationPauseEventCallbackDelegate != null)
+            {
+                this.PauseSignal().Disconnect(_applicationPauseEventCallbackDelegate);
+            }
+
+            if (_applicationResumeEventCallbackDelegate != null)
+            {
+                this.ResumeSignal().Disconnect(_applicationResumeEventCallbackDelegate);
+            }
+
+            if (_applicationResetEventCallbackDelegate != null)
+            {
+                this.ResetSignal().Disconnect(_applicationResetEventCallbackDelegate);
+            }
+
+            if (_applicationResizeEventCallbackDelegate != null)
+            {
+                this.ResizeSignal().Disconnect(_applicationResizeEventCallbackDelegate);
+            }
+
+            if (_applicationLanguageChangedEventCallbackDelegate != null)
+            {
+                this.LanguageChangedSignal().Disconnect(_applicationLanguageChangedEventCallbackDelegate);
+            }
+
+            if (_applicationRegionChangedEventCallbackDelegate != null)
+            {
+                this.RegionChangedSignal().Disconnect(_applicationRegionChangedEventCallbackDelegate);
+            }
+
+            if (_applicationBatteryLowEventCallbackDelegate != null)
+            {
+                this.BatteryLowSignal().Disconnect(_applicationBatteryLowEventCallbackDelegate);
+            }
+
+            if (_applicationMemoryLowEventCallbackDelegate != null)
+            {
+                this.MemoryLowSignal().Disconnect(_applicationMemoryLowEventCallbackDelegate);
+            }
+
+            if (_applicationAppControlEventCallbackDelegate != null)
+            {
+                this.AppControlSignal().Disconnect(_applicationAppControlEventCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 956a3c6..e0f21c5 100755 (executable)
@@ -151,7 +151,7 @@ namespace Tizen.NUI
             get
             {
                 global::System.IntPtr cPtr = NDalicPINVOKE.TouchPoint_hitActor_get(swigCPtr);
-                View ret = (cPtr == global::System.IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromRefObject(cPtr) as View;
+                View ret = (cPtr == global::System.IntPtr.Zero) ? null : Registry.GetManagedBaseHandleFromNativePtr(cPtr) as View;
                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 return ret;
             }
index 94e182e..361ce7e 100755 (executable)
@@ -215,7 +215,7 @@ namespace Tizen.NUI
         public VisualBase GetVisual(int index)
         {
             System.IntPtr cPtr = NDalicManualPINVOKE.ViewWrapperImpl_GetVisual(swigCPtr, index);
-            VisualBase ret = Registry.GetManagedBaseHandleFromRefObject(cPtr) as VisualBase;
+            VisualBase ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as VisualBase;
 
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             return ret;
index 47815a6..208ba3b 100755 (executable)
@@ -61,6 +61,17 @@ namespace Tizen.NUI
                 //You should release all of your own disposable objects here.
             }
 
+            if (_animationFinishedEventCallback != null)
+            {
+                FinishedSignal().Disconnect(_animationFinishedEventCallback);
+            }
+
+            if (_animationProgressReachedEventCallback != null)
+            {
+
+                ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback);
+            }
+
             //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.
@@ -184,7 +195,7 @@ namespace Tizen.NUI
                     Tizen.Log.Debug("NUI", "discon1) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
                     Tizen.Log.Debug("NUI", "discon2) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
 #endif
-                    ProgressReachedSignal().Disconnect(_animationProgressReachedEventHandler);
+                    ProgressReachedSignal().Disconnect(_animationProgressReachedEventCallback);
 #if DEBUG_ON
                     Tizen.Log.Debug("NUI", "discon3) ProgressReachedSignal().Empty = " + ProgressReachedSignal().Empty());
                     Tizen.Log.Debug("NUI", "discon4) ProgressReachedSignal().GetConnectionCount = " + ProgressReachedSignal().GetConnectionCount());
index 37b8cfd..37f26bb 100755 (executable)
@@ -53,6 +53,21 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_scrollableCompletedCallbackDelegate != null)
+            {
+                this.ScrollCompletedSignal().Disconnect(_scrollableCompletedCallbackDelegate);
+            }
+
+            if (_scrollableUpdatedCallbackDelegate != null)
+            {
+                this.ScrollUpdatedSignal().Disconnect(_scrollableUpdatedCallbackDelegate);
+            }
+
+            if (_scrollableStartedCallbackDelegate != null)
+            {
+                this.ScrollStartedSignal().Disconnect(_scrollableStartedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 288a477..16d6dae 100755 (executable)
@@ -58,6 +58,11 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_textEditorTextChangedCallbackDelegate != null)
+            {
+                TextChangedSignal().Disconnect(_textEditorTextChangedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index bcf1a09..2040b7b 100755 (executable)
@@ -59,6 +59,16 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_textFieldMaxLengthReachedCallbackDelegate != null)
+            {
+                this.MaxLengthReachedSignal().Disconnect(_textFieldMaxLengthReachedCallbackDelegate);
+            }
+
+            if (_textFieldTextChangedCallbackDelegate != null)
+            {
+                TextChangedSignal().Disconnect(_textFieldTextChangedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 0c8e0de..ae73ef1 100755 (executable)
@@ -55,6 +55,11 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_videoViewFinishedCallbackDelegate != null)
+            {
+                FinishedSignal().Disconnect(_videoViewFinishedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index bb9b0d6..2eff066 100755 (executable)
@@ -59,6 +59,86 @@ namespace Tizen.NUI.BaseComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_onRelayoutEventCallback != null)
+            {
+                this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+            }
+
+            if (_offWindowEventCallback != null)
+            {
+                this.OffWindowSignal().Disconnect(_offWindowEventCallback);
+            }
+
+            if (_onWindowEventCallback != null)
+            {
+                this.OnWindowSignal().Disconnect(_onWindowEventCallback);
+            }
+
+            if (_wheelEventCallback != null)
+            {
+                this.WheelEventSignal().Disconnect(_wheelEventCallback);
+            }
+
+            if (_hoverEventCallback != null)
+            {
+                this.HoveredSignal().Disconnect(_hoverEventCallback);
+            }
+
+            if (_touchDataCallback != null)
+            {
+                this.TouchSignal().Disconnect(_touchDataCallback);
+            }
+
+            if (_ResourcesLoadedCallback != null)
+            {
+                this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
+            }
+
+            if (_offWindowEventCallback != null)
+            {
+                this.OffWindowSignal().Disconnect(_offWindowEventCallback);
+            }
+
+            if (_onWindowEventCallback != null)
+            {
+                this.OnWindowSignal().Disconnect(_onWindowEventCallback);
+            }
+
+            if (_wheelEventCallback != null)
+            {
+                this.WheelEventSignal().Disconnect(_wheelEventCallback);
+            }
+
+            if (_hoverEventCallback != null)
+            {
+                this.HoveredSignal().Disconnect(_hoverEventCallback);
+            }
+
+            if (_touchDataCallback != null)
+            {
+                this.TouchSignal().Disconnect(_touchDataCallback);
+            }
+
+            if (_onRelayoutEventCallback != null)
+            {
+                this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+            }
+
+            if (_keyCallback != null)
+            {
+                this.KeyEventSignal().Disconnect(_keyCallback);
+            }
+
+            if (_keyInputFocusLostCallback != null)
+            {
+                this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
+            }
+
+            if (_keyInputFocusGainedCallback != null)
+            {
+                this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 8eb6116..f86c192 100755 (executable)
@@ -65,6 +65,31 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_focusedViewEnterKeyEventCallback2 != null)
+            {
+                FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback2);
+            }
+
+            if (_focusedViewEnterKeyEventCallback != null)
+            {
+                FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback);
+            }
+
+            if (_focusGroupChangedEventCallback != null)
+            {
+                FocusGroupChangedSignal().Disconnect(_focusGroupChangedEventCallback);
+            }
+
+            if (_focusChangedEventCallback != null)
+            {
+                FocusChangedSignal().Disconnect(_focusChangedEventCallback);
+            }
+
+            if (_preFocusChangeCallback != null)
+            {
+                PreFocusChangeSignal().Disconnect(_preFocusChangeCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
@@ -403,7 +428,7 @@ namespace Tizen.NUI
             {
                 _focusedViewEnterKeyEventHandler -= value;
 
-                if (_focusedViewEnterKeyEventCallback == null && FocusedViewEnterKeySignal().Empty() == false)
+                if (_focusedViewEnterKeyEventCallback != null && FocusedViewEnterKeySignal().Empty() == false)
                 {
                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback);
                 }
@@ -724,7 +749,7 @@ namespace Tizen.NUI
             {
                 _focusedViewEnterKeyEventHandler2 -= value;
 
-                if (_focusedViewEnterKeyEventCallback2 == null && FocusedViewEnterKeySignal().Empty() == false)
+                if (_focusedViewEnterKeyEventCallback2 != null && FocusedViewEnterKeySignal().Empty() == false)
                 {
                     FocusedViewEnterKeySignal().Disconnect(_focusedViewEnterKeyEventCallback2);
                 }
index 1868cc3..38d8db1 100755 (executable)
@@ -54,6 +54,36 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_imfKeyboardTypeChangedEventCallback != null)
+            {
+                KeyboardTypeChangedSignal().Disconnect(_imfKeyboardTypeChangedEventCallback);
+            }
+
+            if (_imfManagerLanguageChangedEventCallback != null)
+            {
+                LanguageChangedSignal().Disconnect(_imfManagerLanguageChangedEventCallback);
+            }
+
+            if (_imfManagerResizedEventCallback != null)
+            {
+                ResizedSignal().Disconnect(_imfManagerResizedEventCallback);
+            }
+
+            if (_imfManagerStatusChangedEventCallback != null)
+            {
+                StatusChangedSignal().Disconnect(_imfManagerStatusChangedEventCallback);
+            }
+
+            if (_imfManagerEventReceivedEventCallback != null)
+            {
+                EventReceivedSignal().Disconnect(_imfManagerEventReceivedEventCallback);
+            }
+
+            if (_imfManagerActivatedEventCallback != null)
+            {
+                ActivatedSignal().Disconnect(_imfManagerActivatedEventCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 960b5f4..d579034 100755 (executable)
@@ -63,6 +63,11 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_styleManagerStyleChangedCallbackDelegate != null)
+            {
+                StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index ec2b788..415606b 100755 (executable)
@@ -54,6 +54,11 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_stateChangedEventCallback != null)
+            {
+                StateChangedSignal().Disconnect(_stateChangedEventCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 41c9b7a..f873d6e 100755 (executable)
@@ -62,6 +62,11 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_timerTickCallbackDelegate != null)
+            {
+                TickSignal().Disconnect(_timerTickCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index a67858d..25b6182 100755 (executable)
@@ -72,6 +72,26 @@ namespace Tizen.NUI.UIComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_stateChangedCallback != null)
+            {
+                StateChangedSignal().Disconnect(_stateChangedCallback);
+            }
+
+            if (_releasedCallback != null)
+            {
+                ReleasedSignal().Disconnect(_releasedCallback);
+            }
+
+            if (_pressedCallback != null)
+            {
+                this.PressedSignal().Disconnect(_pressedCallback);
+            }
+
+            if (_clickedCallback != null)
+            {
+                ClickedSignal().Disconnect(_clickedCallback);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 24a606d..a39f012 100755 (executable)
@@ -58,6 +58,31 @@ namespace Tizen.NUI.UIComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_popUpHiddenEventCallbackDelegate != null)
+            {
+                HiddenSignal().Disconnect(_popUpHiddenEventCallbackDelegate);
+            }
+
+            if (_popUpHidingEventCallbackDelegate != null)
+            {
+                HidingSignal().Disconnect(_popUpHidingEventCallbackDelegate);
+            }
+
+            if (_popUpShownEventCallbackDelegate != null)
+            {
+                ShownSignal().Disconnect(_popUpShownEventCallbackDelegate);
+            }
+
+            if (_popUpShowingEventCallbackDelegate != null)
+            {
+                ShowingSignal().Disconnect(_popUpShowingEventCallbackDelegate);
+            }
+
+            if (_popUpOutsideTouchedEventCallbackDelegate != null)
+            {
+                this.OutsideTouchedSignal().Disconnect(_popUpOutsideTouchedEventCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 978e777..a6bde47 100755 (executable)
@@ -60,6 +60,11 @@ namespace Tizen.NUI.UIComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_progressBarValueChangedCallbackDelegate != null)
+            {
+                ValueChangedSignal().Disconnect(_progressBarValueChangedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 51417f2..9a9a5ad 100755 (executable)
@@ -60,6 +60,16 @@ namespace Tizen.NUI.UIComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_scrollBarScrollPositionIntervalReachedEventCallbackDelegate != null)
+            {
+                ScrollPositionIntervalReachedSignal().Disconnect(_scrollBarScrollPositionIntervalReachedEventCallbackDelegate);
+            }
+
+            if (_scrollBarPanFinishedEventCallbackDelegate != null)
+            {
+                PanFinishedSignal().Disconnect(_scrollBarPanFinishedEventCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index b9bb7ea..67f307f 100755 (executable)
@@ -54,6 +54,11 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_scrollViewSnapStartedCallbackDelegate != null)
+            {
+                this.SnapStartedSignal().Disconnect(_scrollViewSnapStartedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index a7d6882..3bb0e12 100755 (executable)
@@ -60,6 +60,21 @@ namespace Tizen.NUI.UIComponents
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_sliderValueChangedCallbackDelegate != null)
+            {
+                ValueChangedSignal().Disconnect(_sliderValueChangedCallbackDelegate);
+            }
+
+            if (_sliderSlidingFinishedCallbackDelegate != null)
+            {
+                SlidingFinishedSignal().Disconnect(_sliderSlidingFinishedCallbackDelegate);
+            }
+
+            if (_sliderMarkReachedCallbackDelegate != null)
+            {
+                MarkReachedSignal().Disconnect(_sliderMarkReachedCallbackDelegate);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)
index 6a1e21a..f8a0767 100755 (executable)
@@ -66,6 +66,56 @@ namespace Tizen.NUI
             //You should not access any managed member here except static instance.
             //because the execution order of Finalizes is non-deterministic.
 
+            if (_windowFocusChangedEventCallback != null)
+            {
+                WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
+            }
+
+            if (_stageTouchCallbackDelegate != null)
+            {
+                TouchSignal().Disconnect(_stageTouchCallbackDelegate);
+            }
+
+            if (_stageWheelCallbackDelegate != null)
+            {
+                WheelEventSignal().Disconnect(_stageWheelCallbackDelegate);
+            }
+
+            if (_stageKeyCallbackDelegate != null)
+            {
+                KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
+            }
+
+            if (_stageEventProcessingFinishedEventCallbackDelegate != null)
+            {
+                EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
+            }
+
+            if (_stageContextLostEventCallbackDelegate != null)
+            {
+                ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
+            }
+
+            if (_stageContextRegainedEventCallbackDelegate != null)
+            {
+                this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
+            }
+
+            if (_stageSceneCreatedEventCallbackDelegate != null)
+            {
+                SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
+            }
+
+            if (_windowResizedEventCallback != null)
+            {
+                ResizedSignal().Disconnect(_windowResizedEventCallback);
+            }
+
+            if (_windowFocusChangedEventCallback2 != null)
+            {
+                WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
+            }
+
             if (swigCPtr.Handle != global::System.IntPtr.Zero)
             {
                 if (swigCMemOwn)