summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2015-07-10 15:26:01 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2015-07-10 15:29:12 +0900
commita85c9466bfd17fd51bb270729b0466791ce1db14 (patch)
tree1702b6b5ed2dfc92de596504f4add263ed76ef20
parent72de26e9a367b9bff327192a473979d4fc3ca584 (diff)
Elm.Colorselector: Fix crash in infinite callback loop
In most cases the code would not crash (I can't understand why), but in some cases Eo would complain about call stack overflow. Yep, that's a lot of recursive calls. The mouse_down callback was trying to cancel its triggering event and then send again the same mouse_down event. Why? I guess because it was easier that also having a callback for move (drag the colorselector arrows). Ugly... This widget is in dire need for some love.
-rw-r--r--src/lib/elm_colorselector.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c
index d45ace5e1..b536e456c 100644
--- a/src/lib/elm_colorselector.c
+++ b/src/lib/elm_colorselector.c
@@ -794,34 +794,55 @@ _arrow_cb(void *data,
794} 794}
795 795
796static void 796static void
797_colorbar_cb(void *data, 797_colorbar_arrow_set(Color_Bar_Data *cb_data, int mouse_x)
798 Evas *e,
799 Evas_Object *obj EINA_UNUSED,
800 void *event_info)
801{ 798{
802 Evas_Event_Mouse_Down *ev = event_info;
803 Color_Bar_Data *cb_data = data;
804 double arrow_x = 0, arrow_y;
805 Evas_Coord x, y, w, h; 799 Evas_Coord x, y, w, h;
800 double arrow_x = 0, arrow_y;
806 ELM_COLORSELECTOR_DATA_GET(cb_data->parent, sd); 801 ELM_COLORSELECTOR_DATA_GET(cb_data->parent, sd);
807 802
808 evas_object_geometry_get(cb_data->bar, &x, &y, &w, &h); 803 evas_object_geometry_get(cb_data->bar, &x, &y, &w, &h);
809 edje_object_part_drag_value_get 804 edje_object_part_drag_value_get
810 (cb_data->colorbar, "elm.arrow", &arrow_x, &arrow_y); 805 (cb_data->colorbar, "elm.arrow", &arrow_x, &arrow_y);
811 806
812 if (w > 0) arrow_x = (double)(ev->canvas.x - x) / (double)w; 807 if (w > 0) arrow_x = (double)(mouse_x - x) / (double)w;
813 if (arrow_x > 1) arrow_x = 1; 808 if (arrow_x > 1) arrow_x = 1;
814 if (arrow_x < 0) arrow_x = 0; 809 if (arrow_x < 0) arrow_x = 0;
815 edje_object_part_drag_value_set 810 edje_object_part_drag_value_set
816 (cb_data->colorbar, "elm.arrow", arrow_x, arrow_y); 811 (cb_data->colorbar, "elm.arrow", arrow_x, arrow_y);
817 812
818 _update_hsla_from_colorbar(cb_data->parent, cb_data->color_type, arrow_x); 813 _update_hsla_from_colorbar(cb_data->parent, cb_data->color_type, arrow_x);
819 evas_event_feed_mouse_cancel(e, 0, NULL);
820 evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, 0, NULL);
821 sd->sel_color_type = cb_data->color_type; 814 sd->sel_color_type = cb_data->color_type;
822 sd->focused = ELM_COLORSELECTOR_COMPONENTS; 815 sd->focused = ELM_COLORSELECTOR_COMPONENTS;
823} 816}
824 817
818static void
819_colorbar_down_cb(void *data,
820 Evas *e,
821 Evas_Object *obj EINA_UNUSED,
822 void *event_info)
823{
824 Evas_Event_Mouse_Down *ev = event_info;
825 Color_Bar_Data *cb_data = data;
826
827 _colorbar_arrow_set(cb_data, ev->canvas.x);
828}
829
830static void
831_colorbar_move_cb(void *data,
832 Evas *e,
833 Evas_Object *obj EINA_UNUSED,
834 void *event_info)
835{
836 Evas_Event_Mouse_Move *ev = event_info;
837 Color_Bar_Data *cb_data = data;
838 ELM_COLORSELECTOR_DATA_GET(cb_data->parent, sd);
839
840 if (!ev->buttons)
841 return;
842
843 _colorbar_arrow_set(cb_data, ev->cur.canvas.x);
844}
845
825static Eina_Bool 846static Eina_Bool
826_button_clicked_cb(void *data, 847_button_clicked_cb(void *data,
827 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) 848 Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
@@ -997,8 +1018,9 @@ _color_bars_add(Evas_Object *obj)
997 (sd->cb_data[i]->colorbar, "elm.arrow_bg", 1018 (sd->cb_data[i]->colorbar, "elm.arrow_bg",
998 sd->cb_data[i]->touch_area); 1019 sd->cb_data[i]->touch_area);
999 evas_object_event_callback_add 1020 evas_object_event_callback_add
1000 (sd->cb_data[i]->touch_area, EVAS_CALLBACK_MOUSE_DOWN, _colorbar_cb, 1021 (sd->cb_data[i]->touch_area, EVAS_CALLBACK_MOUSE_DOWN, _colorbar_down_cb, sd->cb_data[i]);
1001 sd->cb_data[i]); 1022 evas_object_event_callback_add
1023 (sd->cb_data[i]->touch_area, EVAS_CALLBACK_MOUSE_MOVE, _colorbar_move_cb, sd->cb_data[i]);
1002 elm_widget_sub_object_add(obj, sd->cb_data[i]->touch_area); 1024 elm_widget_sub_object_add(obj, sd->cb_data[i]->touch_area);
1003 1025
1004 // ACCESS 1026 // ACCESS