summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <hermet@hermet.pe.kr>2016-01-02 21:46:53 +0900
committerHermet Park <hermet@hermet.pe.kr>2016-01-02 21:51:57 +0900
commit12e645b7466a61573f090cbe4e1a18669ccb26c2 (patch)
tree59f530b12e00c53adb5259dd01d98b4519d3c2b7
parentaef9d23550bbcd74829a5d75d5226ba394a9da87 (diff)
tooltip : prevent blowing memory up in the middle of function.
user may remove a tooltip in their callbacks. this patch is just a sort of the defensive code.
-rw-r--r--src/lib/els_tooltip.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/lib/els_tooltip.c b/src/lib/els_tooltip.c
index 32a8dcada..3cf56e6b8 100644
--- a/src/lib/els_tooltip.c
+++ b/src/lib/els_tooltip.c
@@ -58,11 +58,13 @@ struct _Elm_Tooltip
58 } rel_pos; 58 } rel_pos;
59 Elm_Tooltip_Orient orient; /** orientation for tooltip */ 59 Elm_Tooltip_Orient orient; /** orientation for tooltip */
60 int move_freeze; 60 int move_freeze;
61 unsigned short ref;
61 62
62 double hide_timeout; /* from theme */ 63 double hide_timeout; /* from theme */
63 Eina_Bool visible_lock:1; 64 Eina_Bool visible_lock:1;
64 Eina_Bool changed_style:1; 65 Eina_Bool changed_style:1;
65 Eina_Bool free_size : 1; 66 Eina_Bool free_size : 1;
67 Eina_Bool unset_me : 1;
66}; 68};
67 69
68static void _elm_tooltip_reconfigure(Elm_Tooltip *tt); 70static void _elm_tooltip_reconfigure(Elm_Tooltip *tt);
@@ -73,6 +75,7 @@ static void _elm_tooltip_hide_anim_stop(Elm_Tooltip *tt);
73static void _elm_tooltip_show_timer_stop(Elm_Tooltip *tt); 75static void _elm_tooltip_show_timer_stop(Elm_Tooltip *tt);
74static void _elm_tooltip_hide(Elm_Tooltip *tt); 76static void _elm_tooltip_hide(Elm_Tooltip *tt);
75static void _elm_tooltip_data_clean(Elm_Tooltip *tt); 77static void _elm_tooltip_data_clean(Elm_Tooltip *tt);
78static void _elm_tooltip_unset(Elm_Tooltip *tt);
76 79
77static void 80static void
78_elm_tooltip_content_changed_hints_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 81_elm_tooltip_content_changed_hints_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
@@ -354,7 +357,15 @@ _elm_tooltip_reconfigure(Elm_Tooltip *tt)
354 357
355 if (!tt->content) 358 if (!tt->content)
356 { 359 {
360 tt->ref++;
357 tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner); 361 tt->content = tt->func((void *)tt->data, tt->owner, tt->tt_win ? : tt->owner);
362 tt->ref--;
363 if (tt->unset_me)
364 {
365 _elm_tooltip_unset(tt);
366 return;
367 }
368
358 if (!tt->content) 369 if (!tt->content)
359 { 370 {
360 WRN("could not create tooltip content!"); 371 WRN("could not create tooltip content!");
@@ -697,6 +708,11 @@ static void _elm_tooltip_obj_free_cb(void *data, Evas *e EINA_UNUSED, Evas_Obje
697static void 708static void
698_elm_tooltip_unset(Elm_Tooltip *tt) 709_elm_tooltip_unset(Elm_Tooltip *tt)
699{ 710{
711 if (tt->ref > 0)
712 {
713 tt->unset_me = EINA_TRUE;
714 return;
715 }
700 tt->visible_lock = EINA_FALSE; 716 tt->visible_lock = EINA_FALSE;
701 _elm_tooltip_hide(tt); 717 _elm_tooltip_hide(tt);
702 _elm_tooltip_data_clean(tt); 718 _elm_tooltip_data_clean(tt);