elm_panel: prevent redundant callback function addition or deletion 77/167177/1
authorJaeun Choi <jaeun12.choi@samsung.com>
Mon, 8 Jan 2018 08:23:51 +0000 (17:23 +0900)
committerJaeun Choi <jaeun12.choi@samsung.com>
Tue, 16 Jan 2018 04:59:46 +0000 (13:59 +0900)
there is a need to check if callback functions already exist or not
before adding or deleting them, because they are added or deleted
at two points:
in _elm_panel_scrollable_set() and _elm_panel_elm_widget_disable().

Change-Id: Ieb534ce6842a9fc8577d4608b21953cf52d49a26
origin: upstream (65b828b050abc56a1aee4f722535de3e0bea5fbb)

src/lib/elm_panel.c
src/lib/elm_widget_panel.h

index 0173764..cfd83fb 100644 (file)
@@ -1625,7 +1625,7 @@ _elm_panel_elm_widget_disable(Eo *obj, Elm_Panel_Data *sd)
 
    if (sd->scrollable)
      {
-        if (elm_widget_disabled_get(obj))
+        if (elm_widget_disabled_get(obj) && sd->callback_added)
           {
              evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN,
                                             _on_mouse_down);
@@ -1635,8 +1635,10 @@ _elm_panel_elm_widget_disable(Eo *obj, Elm_Panel_Data *sd)
                                             _on_mouse_up);
              evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
                                             _event_mouse_up);
+
+             sd->callback_added = EINA_FALSE;
           }
-        else
+        else if (!elm_widget_disabled_get(obj) && !sd->callback_added)
           {
              evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
                                             _on_mouse_down, sd);
@@ -1646,6 +1648,8 @@ _elm_panel_elm_widget_disable(Eo *obj, Elm_Panel_Data *sd)
                                             _on_mouse_up, sd);
              evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
                                             _event_mouse_up, obj);
+
+             sd->callback_added = EINA_TRUE;
           }
      }
 
@@ -1792,7 +1796,7 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
         eo_do(obj, elm_interface_scrollable_single_direction_set
               (ELM_SCROLLER_SINGLE_DIRECTION_NONE));
 
-        if (!elm_widget_disabled_get(obj))
+        if (!elm_widget_disabled_get(obj) && !sd->callback_added)
           {
              evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
                                             _on_mouse_down, sd);
@@ -1802,6 +1806,8 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
                                             _on_mouse_up, sd);
              evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
                                             _event_mouse_up, obj);
+
+             sd->callback_added = EINA_TRUE;
           }
 
      }
@@ -1809,11 +1815,16 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
      {
         eo_do(obj, elm_interface_scrollable_content_set(NULL));
 
-        evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down);
-        evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move);
-        evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up);
-        evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
-                                       _event_mouse_up);
+        if (sd->callback_added)
+          {
+             evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down);
+             evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move);
+             evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up);
+             evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
+                                            _event_mouse_up);
+
+             sd->callback_added = EINA_FALSE;
+          }
 
         elm_widget_resize_object_set(obj, NULL, EINA_TRUE);
         elm_widget_sub_object_add(obj, sd->scr_edje);
index 4e9c571..4434960 100644 (file)
@@ -49,6 +49,7 @@ struct _Elm_Panel_Data
    // TIZEN_ONLY(20170105): scrollable panel content size ratio refactoring (for 2.4 UX)
    Eina_Bool                             content_size_manual_set: 1;
    //
+   Eina_Bool                             callback_added: 1;
 };
 
 /**