[NUI] Add defence codes for specific events
authordongsug.song <dongsug.song@samsung.com>
Tue, 18 Apr 2023 07:26:24 +0000 (16:26 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 18 Apr 2023 09:35:00 +0000 (18:35 +0900)
src/Tizen.NUI/src/public/Accessibility/AccessibilityManagerEvent.cs
src/Tizen.NUI/src/public/Animation.cs
src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs
src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs
src/Tizen.NUI/src/public/PropertyNotification.cs
src/Tizen.NUI/src/public/StyleManager.cs
src/Tizen.NUI/src/public/Timer.cs
src/Tizen.NUI/src/public/WindowEvent.cs

index f08d42f..ad68065 100755 (executable)
@@ -1114,23 +1114,28 @@ namespace Tizen.NUI.Accessibility
         {
             add
             {
-                // Restricted to only one listener
                 if (_accessibilityManagerFocusedViewActivatedEventHandler == null)
                 {
-                    _accessibilityManagerFocusedViewActivatedEventCallbackDelegate = new FocusedViewActivatedEventCallbackDelegate(OnFocusedViewActivated);
-                    this.FocusedViewActivatedSignal().Connect(_accessibilityManagerFocusedViewActivatedEventCallbackDelegate);
+                    _accessibilityManagerFocusedViewActivatedEventCallbackDelegate = OnFocusedViewActivated;
+                    var signal = FocusedViewActivatedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Connect(_accessibilityManagerFocusedViewActivatedEventCallbackDelegate);
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
-
                 _accessibilityManagerFocusedViewActivatedEventHandler += value;
             }
-
             remove
             {
                 _accessibilityManagerFocusedViewActivatedEventHandler -= value;
-
-                if (_accessibilityManagerFocusedViewActivatedEventHandler == null && FocusedViewActivatedSignal().Empty() == false)
+                if (_accessibilityManagerFocusedViewActivatedEventHandler == null && _accessibilityManagerFocusedViewActivatedEventCallbackDelegate != null)
                 {
-                    this.FocusedViewActivatedSignal().Disconnect(_accessibilityManagerFocusedViewActivatedEventCallbackDelegate);
+                    var signal = FocusedViewActivatedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_accessibilityManagerFocusedViewActivatedEventCallbackDelegate);
+                    _accessibilityManagerFocusedViewActivatedEventCallbackDelegate = null;
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
index 682f2b4..71c746c 100755 (executable)
@@ -47,6 +47,7 @@ namespace Tizen.NUI
 
         private AnimationFinishedEventCallbackType _animationFinishedEventCallback;
         private System.IntPtr _finishedCallbackOfNative;
+        private bool isFinishedSignalConnected = false;
 
         private AnimationProgressReachedEventCallbackType _animationProgressReachedEventCallback;
 
@@ -74,6 +75,7 @@ namespace Tizen.NUI
 
             _animationFinishedEventCallback = OnFinished;
             _finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(_animationFinishedEventCallback);
+            isFinishedSignalConnected = false;
         }
 
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
@@ -93,19 +95,28 @@ namespace Tizen.NUI
         {
             add
             {
-                if (_animationFinishedEventHandler == null && disposed == false)
+                if (_animationFinishedEventHandler == null && disposed == false && isFinishedSignalConnected == false)
                 {
-                    FinishedSignal().Connect(_finishedCallbackOfNative);
+                    var signal = FinishedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Connect(_finishedCallbackOfNative);
+                    signal?.Dispose();
+                    isFinishedSignalConnected = true;
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _animationFinishedEventHandler += value;
             }
             remove
             {
                 _animationFinishedEventHandler -= value;
-
-                if (_animationFinishedEventHandler == null && FinishedSignal().Empty() == false)
+                if (_animationFinishedEventHandler == null && isFinishedSignalConnected)
                 {
-                    FinishedSignal().Disconnect(_finishedCallbackOfNative);
+                    var signal = FinishedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_finishedCallbackOfNative);
+                    signal?.Dispose();
+                    isFinishedSignalConnected = false;
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -1288,10 +1299,15 @@ namespace Tizen.NUI
                 return;
             }
 
-            if (_animationFinishedEventHandler != null)
+            if (_animationFinishedEventHandler != null && isFinishedSignalConnected)
             {
-                FinishedSignal().Disconnect(_finishedCallbackOfNative);
+                var signal = FinishedSignal();
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                signal?.Disconnect(_finishedCallbackOfNative);
+                signal?.Dispose();
+                isFinishedSignalConnected = false;
                 _animationFinishedEventHandler = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_animationProgressReachedEventCallback != null)
@@ -1308,7 +1324,7 @@ namespace Tizen.NUI
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
         {
-            if(swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
+            if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
             {
                 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
                 return;
index 4c15cca..bd404a1 100755 (executable)
@@ -184,23 +184,24 @@ namespace Tizen.NUI.BaseComponents
                 {
                     _keyCallback = OnKeyEvent;
                     var signal = KeyEventSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                     signal?.Connect(_keyCallback);
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _keyEventHandler += value;
             }
             remove
             {
                 _keyEventHandler -= value;
-                if (_keyEventHandler == null)
+                if (_keyEventHandler == null && _keyCallback != null)
                 {
                     var signal = KeyEventSignal();
-                    if (signal?.Empty() == false)
-                    {
-                        signal?.Disconnect(_keyCallback);
-                        _keyCallback = null;
-                    }
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_keyCallback);
+                    _keyCallback = null;
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -301,23 +302,24 @@ namespace Tizen.NUI.BaseComponents
                 {
                     _touchDataCallback = OnTouch;
                     var signal = TouchSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                     signal?.Connect(_touchDataCallback);
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _touchDataEventHandler += value;
             }
             remove
             {
                 _touchDataEventHandler -= value;
-                if (_touchDataEventHandler == null)
+                if (_touchDataEventHandler == null && _touchDataCallback != null)
                 {
                     var signal = TouchSignal();
-                    if (signal?.Empty() == false)
-                    {
-                        signal?.Disconnect(_touchDataCallback);
-                        _touchDataCallback = null;
-                    }
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_touchDataCallback);
+                    _touchDataCallback = null;
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -449,23 +451,24 @@ namespace Tizen.NUI.BaseComponents
                 {
                     _offWindowEventCallback = OffWindow;
                     var signal = OffWindowSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                     signal?.Connect(_offWindowEventCallback);
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _offWindowEventHandler += value;
             }
             remove
             {
                 _offWindowEventHandler -= value;
-                if (_offWindowEventHandler == null)
+                if (_offWindowEventHandler == null && _offWindowEventCallback != null)
                 {
                     var signal = OffWindowSignal();
-                    if (signal?.Empty() == false)
-                    {
-                        signal?.Disconnect(_offWindowEventCallback);
-                        _offWindowEventCallback = null;
-                    }
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_offWindowEventCallback);
+                    _offWindowEventCallback = null;
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -924,7 +927,7 @@ namespace Tizen.NUI.BaseComponents
                 NUILog.Error("implicit disposed(unreachable)! just return here!");
                 return true;
             }
-            
+
             if (touchData == global::System.IntPtr.Zero)
             {
                 NUILog.Error("touchData should not be null!");
index 77113d1..59dcd56 100755 (executable)
@@ -1131,7 +1131,7 @@ 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.
-            
+
             DisConnectFromSignals();
 
             foreach (View view in Children)
@@ -1194,9 +1194,11 @@ namespace Tizen.NUI.BaseComponents
             if (_offWindowEventCallback != null)
             {
                 ViewSignal signal = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(GetBaseHandleCPtrHandleRef), false);
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                 signal?.Disconnect(_offWindowEventCallback);
                 signal?.Dispose();
                 _offWindowEventCallback = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_onWindowEventCallback != null)
@@ -1239,9 +1241,11 @@ namespace Tizen.NUI.BaseComponents
             if (_touchDataCallback != null)
             {
                 TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(GetBaseHandleCPtrHandleRef), false);
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                 signal?.Disconnect(_touchDataCallback);
                 signal?.Dispose();
                 _touchDataCallback = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_ResourcesLoadedCallback != null)
@@ -1255,9 +1259,11 @@ namespace Tizen.NUI.BaseComponents
             if (_keyCallback != null)
             {
                 ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                 signal?.Disconnect(_keyCallback);
                 signal?.Dispose();
                 _keyCallback = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_keyInputFocusLostCallback != null)
index 6fa83fe..0763d95 100755 (executable)
@@ -1,5 +1,5 @@
 /*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -28,10 +28,12 @@ namespace Tizen.NUI
     /// <since_tizen> 4 </since_tizen>
     public class PropertyNotification : BaseHandle
     {
+        #region Fields
+        private DaliEventHandler<object, NotifyEventArgs> notifiedEventHandler;
+        private NotifyEventCallbackDelegate notifySignalCallback;
+        #endregion //#region Fields
 
-        private DaliEventHandler<object, NotifyEventArgs> _propertyNotificationNotifyEventHandler;
-        private NotifyEventCallbackDelegate _propertyNotificationNotifyEventCallbackDelegate;
-
+        #region Constructors
         /// <summary>
         /// Create a instance of PropertyNotification.
         /// </summary>
@@ -53,10 +55,58 @@ namespace Tizen.NUI
         internal PropertyNotification(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.PropertyNotification.PropertyNotification_SWIGUpcast(cPtr), cMemoryOwn)
         {
         }
+        #endregion //#region Constructors
+
+        #region Distructors
+        /// <summary>
+        /// you can override it to clean-up your own resources.
+        /// </summary>
+        /// <param name="type">DisposeTypes</param>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void Dispose(DisposeTypes type)
+        {
+            if (disposed)
+            {
+                return;
+            }
+
+            if (notifySignalCallback != null)
+            {
+                var signal = NotifySignal();
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                signal?.Disconnect(notifySignalCallback);
+                notifySignalCallback = null;
+                signal?.Dispose();
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            }
+
+            if (type == DisposeTypes.Explicit)
+            {
+                //Called by User
+                //Release your own managed resources here.
+                //You should release all of your own disposable objects here.
+            }
+            //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.
+
+            base.Dispose(type);
+        }
 
+        // This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+        {
+            Interop.PropertyNotification.delete_PropertyNotification(swigCPtr);
+        }
+        #endregion //#region Distructors
+
+        #region Delegates
         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
         private delegate void NotifyEventCallbackDelegate(IntPtr propertyNotification);
+        #endregion //#region Delegates
 
+        #region Events
         ///<summary>
         /// Event for Notified signal which can be used to subscribe/unsubscribe the event handler
         /// Notified signal is emitted when the notification upon a condition of the property being met, has occurred.
@@ -66,33 +116,59 @@ namespace Tizen.NUI
         {
             add
             {
-                lock (this)
+                if (notifiedEventHandler == null)
                 {
-                    // Restricted to only one listener
-                    if (_propertyNotificationNotifyEventHandler == null)
-                    {
-                        _propertyNotificationNotifyEventHandler += value;
-
-                        _propertyNotificationNotifyEventCallbackDelegate = new NotifyEventCallbackDelegate(OnPropertyNotificationNotify);
-                        this.NotifySignal().Connect(_propertyNotificationNotifyEventCallbackDelegate);
-                    }
+                    notifySignalCallback = OnPropertyNotificationNotify;
+                    var signal = NotifySignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Connect(notifySignalCallback);
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
+                notifiedEventHandler += value;
             }
-
             remove
             {
-                lock (this)
+                notifiedEventHandler -= value;
+                if (notifiedEventHandler == null && notifySignalCallback != null)
                 {
-                    if (_propertyNotificationNotifyEventHandler != null)
-                    {
-                        this.NotifySignal().Disconnect(_propertyNotificationNotifyEventCallbackDelegate);
-                    }
+                    var signal = NotifySignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(notifySignalCallback);
+                    notifySignalCallback = null;
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+                }
+            }
+        }
 
-                    _propertyNotificationNotifyEventHandler -= value;
+        ///<summary>
+        /// Event arguments that passed via Notify signal
+        ///</summary>
+        /// <since_tizen> 3 </since_tizen>
+        public class NotifyEventArgs : EventArgs
+        {
+            private PropertyNotification propertyNotification;
+
+            ///<summary>
+            /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
+            ///</summary>
+            /// <since_tizen> 3 </since_tizen>
+            public PropertyNotification PropertyNotification
+            {
+                get
+                {
+                    return propertyNotification;
+                }
+                set
+                {
+                    propertyNotification = value;
                 }
             }
         }
+        #endregion //#region Events
 
+        #region Enums
         /// <summary>
         /// Enumeration for description of how to check condition.
         /// </summary>
@@ -120,25 +196,9 @@ namespace Tizen.NUI
             /// <since_tizen> 3 </since_tizen>
             NotifyOnChanged
         }
+        #endregion //#region Enums
 
-        /// <summary>
-        /// Get property notification from Intptr.<br/>
-        /// This should be internal, please do not use.
-        /// </summary>
-        /// <param name="cPtr">An object of IntPtr type.</param>
-        /// <returns>An object of the PropertyNotification type.</returns>
-        /// <since_tizen> 4 </since_tizen>
-        [Obsolete("Deprecated in API6, Will be removed in API9, " + 
-            "Please use Notified event instead!" +
-            "IntPtr(native integer pointer) is supposed to be not used in Application!")]
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
-        {
-            PropertyNotification ret = new PropertyNotification(cPtr, false);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
+        #region Methods
         /// <summary>
         /// Downcast a PropertyNotification instance.
         /// </summary>
@@ -153,22 +213,6 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// Assign.
-        /// </summary>
-        /// <param name="rhs">A reference to the copied handle.</param>
-        /// <returns>A reference to this.</returns>
-        /// <since_tizen> 4 </since_tizen>
-        [Obsolete("Deprecated in API6, Will be removed in API9, " + 
-            "Please use PropertyNotification() constructor instead!")]
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        public PropertyNotification Assign(PropertyNotification rhs)
-        {
-            PropertyNotification ret = new PropertyNotification(Interop.PropertyNotification.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
-            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
-        }
-
-        /// <summary>
         /// Gets the condition of this notification.
         /// </summary>
         /// <returns>The condition is returned.</returns>
@@ -239,11 +283,45 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Get property notification from Intptr.<br/>
+        /// This should be internal, please do not use.
+        /// </summary>
+        /// <param name="cPtr">An object of IntPtr type.</param>
+        /// <returns>An object of the PropertyNotification type.</returns>
+        /// <since_tizen> 4 </since_tizen>
+        [Obsolete("Deprecated in API6, Will be removed in API9, " +
+            "Please use Notified event instead!" +
+            "IntPtr(native integer pointer) is supposed to be not used in Application!")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static PropertyNotification GetPropertyNotificationFromPtr(global::System.IntPtr cPtr)
+        {
+            PropertyNotification ret = new PropertyNotification(cPtr, false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
+        /// Assign.
+        /// </summary>
+        /// <param name="rhs">A reference to the copied handle.</param>
+        /// <returns>A reference to this.</returns>
+        /// <since_tizen> 4 </since_tizen>
+        [Obsolete("Deprecated in API6, Will be removed in API9, " +
+            "Please use PropertyNotification() constructor instead!")]
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public PropertyNotification Assign(PropertyNotification rhs)
+        {
+            PropertyNotification ret = new PropertyNotification(Interop.PropertyNotification.PropertyNotification_Assign(swigCPtr, PropertyNotification.getCPtr(rhs)), false);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
+        /// <summary>
         /// Connects to this signal to be notified when the notification has occurred.
         /// </summary>
         /// <returns>A signal object to Connect() with</returns>
         /// <since_tizen> 4 </since_tizen>
-        [Obsolete("Deprecated in API6, Will be removed in API9, " + 
+        [Obsolete("Deprecated in API6, Will be removed in API9, " +
             "Please use Notified event instead!")]
         [EditorBrowsable(EditorBrowsableState.Never)]
         public PropertyNotifySignal NotifySignal()
@@ -258,49 +336,18 @@ namespace Tizen.NUI
             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
         }
 
-        /// This will not be public opened.
-        [EditorBrowsable(EditorBrowsableState.Never)]
-        protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
-        {
-            Interop.PropertyNotification.delete_PropertyNotification(swigCPtr);
-        }
-
         // Callback for PropertyNotification NotifySignal
         private void OnPropertyNotificationNotify(IntPtr propertyNotification)
         {
             NotifyEventArgs e = new NotifyEventArgs();
             e.PropertyNotification = GetPropertyNotificationFromPtr(propertyNotification);
 
-            if (_propertyNotificationNotifyEventHandler != null)
+            if (notifiedEventHandler != null)
             {
                 //here we send all data to user event handlers
-                _propertyNotificationNotifyEventHandler(this, e);
-            }
-        }
-
-        ///<summary>
-        /// Event arguments that passed via Notify signal
-        ///</summary>
-        /// <since_tizen> 3 </since_tizen>
-        public class NotifyEventArgs : EventArgs
-        {
-            private PropertyNotification _propertyNotification;
-
-            ///<summary>
-            /// PropertyNotification - is the PropertyNotification handle that has the notification properties.
-            ///</summary>
-            /// <since_tizen> 3 </since_tizen>
-            public PropertyNotification PropertyNotification
-            {
-                get
-                {
-                    return _propertyNotification;
-                }
-                set
-                {
-                    _propertyNotification = value;
-                }
+                notifiedEventHandler(this, e);
             }
         }
+        #endregion //#region Methods
     }
 }
index 2484c1f..af191be 100755 (executable)
@@ -62,17 +62,26 @@ namespace Tizen.NUI
             {
                 if (_styleManagerStyleChangedEventHandler == null)
                 {
-                    _styleManagerStyleChangedCallbackDelegate = (OnStyleChanged);
-                    StyleChangedSignal().Connect(_styleManagerStyleChangedCallbackDelegate);
+                    _styleManagerStyleChangedCallbackDelegate = OnStyleChanged;
+                    var signal = StyleChangedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Connect(_styleManagerStyleChangedCallbackDelegate);
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _styleManagerStyleChangedEventHandler += value;
             }
             remove
             {
                 _styleManagerStyleChangedEventHandler -= value;
-                if (_styleManagerStyleChangedEventHandler == null && StyleChangedSignal().Empty() == false)
+                if (_styleManagerStyleChangedEventHandler == null && _styleManagerStyleChangedCallbackDelegate != null)
                 {
-                    StyleChangedSignal().Disconnect(_styleManagerStyleChangedCallbackDelegate);
+                    var signal = StyleChangedSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_styleManagerStyleChangedCallbackDelegate);
+                    _styleManagerStyleChangedCallbackDelegate = null;
+                    signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
index 134d71a..2e5bd35 100755 (executable)
@@ -40,6 +40,7 @@ namespace Tizen.NUI
         private TickCallbackDelegate _timerTickCallbackDelegate;
 
         private System.IntPtr _timerTickCallbackOfNative;
+        private bool isTickSignalConnected = false;
 
         /// <summary>
         /// Creates a tick timer that emits periodic signal.
@@ -60,10 +61,9 @@ namespace Tizen.NUI
 
         internal Timer(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Timer.Timer_SWIGUpcast(cPtr), cMemoryOwn)
         {
-
             _timerTickCallbackDelegate = OnTick;
             _timerTickCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(_timerTickCallbackDelegate);
-
+            isTickSignalConnected = false;
             NUILog.Debug($"(0x{swigCPtr.Handle:X})Timer() contructor!");
         }
 
@@ -87,18 +87,28 @@ namespace Tizen.NUI
         {
             add
             {
-                if (_timerTickEventHandler == null && disposed == false)
+                if (_timerTickEventHandler == null && disposed == false && isTickSignalConnected == false)
                 {
-                    TickSignal().Connect(_timerTickCallbackOfNative);
+                    var signal = TickSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Connect(_timerTickCallbackOfNative);
+                    signal?.Dispose();
+                    isTickSignalConnected = true;
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _timerTickEventHandler += value;
             }
             remove
             {
                 _timerTickEventHandler -= value;
-                if (_timerTickEventHandler == null && TickSignal().Empty() == false)
+                if (_timerTickEventHandler == null && isTickSignalConnected)
                 {
-                    TickSignal().Disconnect(_timerTickCallbackOfNative);
+                    var signal = TickSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_timerTickCallbackOfNative);
+                    signal?.Dispose();
+                    isTickSignalConnected = false;
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -242,7 +252,7 @@ namespace Tizen.NUI
 
         internal uint GetInterval()
         {
-            if(swigCPtr.Handle == global::System.IntPtr.Zero || disposed)
+            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;
@@ -268,9 +278,14 @@ namespace Tizen.NUI
         {
             NUILog.Debug($"(0x{swigCPtr.Handle:X}) Timer.Dispose(type={type}, disposed={disposed})");
 
-            if (this != null && _timerTickCallbackDelegate != null)
+            if (this != null && _timerTickCallbackDelegate != null && isTickSignalConnected)
             {
-                TickSignal().Disconnect(_timerTickCallbackOfNative);
+                var signal = TickSignal();
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                signal?.Disconnect(_timerTickCallbackOfNative);
+                signal?.Dispose();
+                isTickSignalConnected = false;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (disposed)
index d297fb2..5d635eb 100755 (executable)
@@ -110,23 +110,24 @@ namespace Tizen.NUI
                 {
                     _rootLayerTouchDataCallback = OnWindowTouch;
                     var signal = TouchDataSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                     signal?.Connect(_rootLayerTouchDataCallback);
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _rootLayerTouchDataEventHandler += value;
             }
             remove
             {
                 _rootLayerTouchDataEventHandler -= value;
-                if (_rootLayerTouchDataEventHandler == null)
+                if (_rootLayerTouchDataEventHandler == null && _rootLayerTouchDataCallback != null)
                 {
                     var signal = TouchDataSignal();
-                    if (signal?.Empty() == false)
-                    {
-                        signal?.Disconnect(_rootLayerTouchDataCallback);
-                        _rootLayerTouchDataCallback = null;
-                    }
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_rootLayerTouchDataCallback);
+                    _rootLayerTouchDataCallback = null;
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -176,23 +177,24 @@ namespace Tizen.NUI
                 {
                     _stageKeyCallbackDelegate = OnStageKey;
                     var signal = KeyEventSignal();
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                     signal?.Connect(_stageKeyCallbackDelegate);
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
                 _stageKeyHandler += value;
             }
             remove
             {
                 _stageKeyHandler -= value;
-                if (_stageKeyHandler == null)
+                if (_stageKeyHandler == null && _stageKeyCallbackDelegate != null)
                 {
                     var signal = KeyEventSignal();
-                    if (signal?.Empty() == false)
-                    {
-                        signal?.Disconnect(_stageKeyCallbackDelegate);
-                        _stageKeyCallbackDelegate = null;
-                    }
+                    if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
+                    signal?.Disconnect(_stageKeyCallbackDelegate);
+                    _stageKeyCallbackDelegate = null;
                     signal?.Dispose();
+                    if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                 }
             }
         }
@@ -577,9 +579,11 @@ namespace Tizen.NUI
             if (_rootLayerTouchDataCallback != null)
             {
                 TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                 signal?.Disconnect(_rootLayerTouchDataCallback);
                 signal?.Dispose();
                 _rootLayerTouchDataCallback = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_wheelEventCallback != null)
@@ -598,9 +602,11 @@ namespace Tizen.NUI
             if (_stageKeyCallbackDelegate != null)
             {
                 KeyEventSignal signal = new KeyEventSignal(Interop.Window.KeyEventSignal(GetBaseHandleCPtrHandleRef), false);
+                if (signal?.SwigCPtr.Handle == IntPtr.Zero) { signal = null; }
                 signal?.Disconnect(_stageKeyCallbackDelegate);
                 signal?.Dispose();
                 _stageKeyCallbackDelegate = null;
+                if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
             }
 
             if (_stageEventProcessingFinishedEventCallbackDelegate != null)