Refactor RenderPost event using EvasEvent 00/120800/3 accepted/tizen_common accepted/tizen_ivi accepted/tizen_mobile accepted/tizen_tv accepted/tizen/common/20170324.123607 accepted/tizen/ivi/20170327.051721 accepted/tizen/mobile/20170327.051639 accepted/tizen/tv/20170327.051659 accepted/tizen/unified/20170327.051736 submit/tizen/20170324.105839
authorjh5.cho <jh5.cho@samsung.com>
Fri, 24 Mar 2017 08:27:09 +0000 (17:27 +0900)
committerjh5.cho <jh5.cho@samsung.com>
Fri, 24 Mar 2017 10:09:11 +0000 (19:09 +0900)
    - RenderPost event is implemented as EvasEvent, not EvasObjectEvent,
      due to the malfuntion under TCT execute envirenment
    - Update Version to Beta-018

Change-Id: Idaf0137f094674d016f1bdf248b8b8ff007a6660

ElmSharp/ElmSharp/EvasObject.cs
ElmSharp/Interop/Interop.Evas.cs [changed mode: 0644->0755]
packaging/elm-sharp.spec

index f9cf919..0b3d8ef 100755 (executable)
@@ -45,7 +45,8 @@ namespace ElmSharp
         EvasObjectEvent<EvasKeyEventArgs> _keydown;
         EvasObjectEvent _moved;
         EvasObjectEvent _resized;
-        EvasObjectEvent _renderPost;
+        EventHandler _renderPost;
+        Interop.Evas.EvasCallback _renderPostCallback = null;
 
         readonly HashSet<IInvalidatable> _eventStore = new HashSet<IInvalidatable>();
 
@@ -103,13 +104,30 @@ namespace ElmSharp
             add { _resized.On += value; }
             remove { _resized.On -= value; }
         }
+
         /// <summary>
         /// Current widget RenderPost Event Handler
         /// </summary>
         public event EventHandler RenderPost
         {
-            add { _renderPost.On += value; }
-            remove { _renderPost.On -= value; }
+            add
+            {
+                _renderPost += value;
+                if (_renderPostCallback == null)
+                {
+                    _renderPostCallback = new Interop.Evas.EvasCallback((o, e, d) => _renderPost?.Invoke(this, EventArgs.Empty));
+                    Interop.Evas.evas_event_callback_add(Interop.Evas.evas_object_evas_get(Handle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback, IntPtr.Zero);
+                }
+            }
+            remove
+            {
+                _renderPost -= value;
+                if (_renderPost?.GetInvocationList().Length == 0)
+                {
+                    Interop.Evas.evas_event_callback_del(Interop.Evas.evas_object_evas_get(Handle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback);
+                    _renderPostCallback = null;
+                }
+            }
         }
 
         /// <summary>
@@ -510,7 +528,6 @@ namespace ElmSharp
                 _keyup = new EvasObjectEvent<EvasKeyEventArgs>(this, EvasObjectCallbackType.KeyUp, EvasKeyEventArgs.Create);
                 _moved = new EvasObjectEvent(this, EvasObjectCallbackType.Move);
                 _resized = new EvasObjectEvent(this, EvasObjectCallbackType.Resize);
-                _renderPost = new EvasObjectEvent(this, Interop.Evas.evas_object_evas_get(Handle), EvasObjectCallbackType.RenderPost);
 
                 _deleted.On += (s, e) => MakeInvalidate();
                 _keydown.On += (s, e) => KeyDown?.Invoke(this, e);
@@ -525,6 +542,12 @@ namespace ElmSharp
         {
             if (IsRealized)
             {
+                if(_renderPostCallback != null)
+                {
+                    Interop.Evas.evas_event_callback_del(Interop.Evas.evas_object_evas_get(Handle), Interop.Evas.ObjectCallbackType.RenderPost, _renderPostCallback);
+                    _renderPostCallback = null;
+                }
+
                 OnUnrealize();
                 IntPtr toBeDeleted = Handle;
                 Handle = IntPtr.Zero;
old mode 100644 (file)
new mode 100755 (executable)
index bbc2b99..6adbb98
@@ -62,6 +62,14 @@ internal static partial class Interop
         }
         internal delegate void EventCallback(IntPtr data, IntPtr evas, IntPtr obj, IntPtr info);
 
+        internal delegate void EvasCallback(IntPtr data, IntPtr evas, IntPtr info);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_event_callback_add(IntPtr obj, ObjectCallbackType type, EvasCallback func, IntPtr data);
+
+        [DllImport(Libraries.Evas)]
+        internal static extern void evas_event_callback_del(IntPtr obj, ObjectCallbackType type, EvasCallback func);
+
         [DllImport(Libraries.Evas)]
         internal static extern void evas_object_event_callback_add(IntPtr obj, ObjectCallbackType type, EventCallback func, IntPtr data);
         [DllImport(Libraries.Evas)]
index 1df2f6c..2f140ee 100644 (file)
@@ -1,4 +1,4 @@
-%define DEV_VERSION beta-017
+%define DEV_VERSION beta-018
 
 Name:       elm-sharp
 Summary:    C# Binding for Elementary