summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaeun Choi <jaeun12.choi@samsung.com>2018-01-16 13:19:36 +0900
committerJaeun Choi <jaeun12.choi@samsung.com>2018-01-16 13:19:36 +0900
commit65b828b050abc56a1aee4f722535de3e0bea5fbb (patch)
treedfb926a26d8f64d98c6e0fd9576cab7ae9bd517b
parent631eb3701d86b1d5b09b4a54c96b55a70fbe777e (diff)
elm_panel: prevent redundant callback function addition or deletion
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().
-rw-r--r--src/lib/elementary/elm_panel.c27
-rw-r--r--src/lib/elementary/elm_widget_panel.h1
2 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/elementary/elm_panel.c b/src/lib/elementary/elm_panel.c
index 79057b72d1..1ccf497193 100644
--- a/src/lib/elementary/elm_panel.c
+++ b/src/lib/elementary/elm_panel.c
@@ -1227,7 +1227,7 @@ _elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bo
1227 1227
1228 if (sd->scrollable) 1228 if (sd->scrollable)
1229 { 1229 {
1230 if (disabled) 1230 if (disabled && sd->callback_added)
1231 { 1231 {
1232 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, 1232 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN,
1233 _on_mouse_down); 1233 _on_mouse_down);
@@ -1237,8 +1237,10 @@ _elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bo
1237 _on_mouse_up); 1237 _on_mouse_up);
1238 evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP, 1238 evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
1239 _event_mouse_up); 1239 _event_mouse_up);
1240
1241 sd->callback_added = EINA_FALSE;
1240 } 1242 }
1241 else 1243 else if (!disabled && !sd->callback_added)
1242 { 1244 {
1243 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, 1245 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1244 _on_mouse_down, sd); 1246 _on_mouse_down, sd);
@@ -1248,6 +1250,8 @@ _elm_panel_efl_ui_widget_on_disabled_update(Eo *obj, Elm_Panel_Data *sd, Eina_Bo
1248 _on_mouse_up, sd); 1250 _on_mouse_up, sd);
1249 evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP, 1251 evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
1250 _event_mouse_up, obj); 1252 _event_mouse_up, obj);
1253
1254 sd->callback_added = EINA_TRUE;
1251 } 1255 }
1252 } 1256 }
1253 1257
@@ -1370,7 +1374,7 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
1370 elm_interface_scrollable_single_direction_set 1374 elm_interface_scrollable_single_direction_set
1371 (obj, ELM_SCROLLER_SINGLE_DIRECTION_NONE); 1375 (obj, ELM_SCROLLER_SINGLE_DIRECTION_NONE);
1372 1376
1373 if (!elm_widget_disabled_get(obj)) 1377 if (!elm_widget_disabled_get(obj) && !sd->callback_added)
1374 { 1378 {
1375 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, 1379 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN,
1376 _on_mouse_down, sd); 1380 _on_mouse_down, sd);
@@ -1380,6 +1384,8 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
1380 _on_mouse_up, sd); 1384 _on_mouse_up, sd);
1381 evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP, 1385 evas_object_event_callback_add(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
1382 _event_mouse_up, obj); 1386 _event_mouse_up, obj);
1387
1388 sd->callback_added = EINA_TRUE;
1383 } 1389 }
1384 1390
1385 } 1391 }
@@ -1387,11 +1393,16 @@ _elm_panel_scrollable_set(Eo *obj, Elm_Panel_Data *sd, Eina_Bool scrollable)
1387 { 1393 {
1388 elm_interface_scrollable_content_set(obj, NULL); 1394 elm_interface_scrollable_content_set(obj, NULL);
1389 1395
1390 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down); 1396 if (sd->callback_added)
1391 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move); 1397 {
1392 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up); 1398 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down);
1393 evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP, 1399 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move);
1394 _event_mouse_up); 1400 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up);
1401 evas_object_event_callback_del(sd->scr_event, EVAS_CALLBACK_MOUSE_UP,
1402 _event_mouse_up);
1403
1404 sd->callback_added = EINA_FALSE;
1405 }
1395 1406
1396 elm_widget_resize_object_set(obj, NULL); 1407 elm_widget_resize_object_set(obj, NULL);
1397 elm_widget_sub_object_add(obj, sd->scr_edje); 1408 elm_widget_sub_object_add(obj, sd->scr_edje);
diff --git a/src/lib/elementary/elm_widget_panel.h b/src/lib/elementary/elm_widget_panel.h
index 16847480a6..6aacb9b585 100644
--- a/src/lib/elementary/elm_widget_panel.h
+++ b/src/lib/elementary/elm_widget_panel.h
@@ -46,6 +46,7 @@ struct _Elm_Panel_Data
46 Eina_Bool delete_me : 1; 46 Eina_Bool delete_me : 1;
47 Eina_Bool scrollable : 1; 47 Eina_Bool scrollable : 1;
48 Eina_Bool freeze: 1; 48 Eina_Bool freeze: 1;
49 Eina_Bool callback_added: 1;
49}; 50};
50 51
51/** 52/**