From 171634468a659b52447540240e795527c313c1ee Mon Sep 17 00:00:00 2001 From: tasn Date: Sun, 28 Aug 2011 14:12:38 +0000 Subject: [PATCH] Elm tooltip: Added checks if the object passed is an elm object. git-svn-id: https://svn.enlightenment.org/svn/e/trunk/elementary@62919 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_widget.c | 17 +++++++++++++++++ src/lib/elm_widget.h | 4 ++++ src/lib/els_tooltip.c | 9 +++++++++ 3 files changed, 30 insertions(+) diff --git a/src/lib/elm_widget.c b/src/lib/elm_widget.c index 14d7c98..8ce4f86 100644 --- a/src/lib/elm_widget.c +++ b/src/lib/elm_widget.c @@ -2530,6 +2530,23 @@ elm_widget_theme_object_set(Evas_Object *obj, } EAPI Eina_Bool +elm_widget_is_check(const Evas_Object *obj) +{ + static int abort_on_warn = -1; + if (elm_widget_is(obj)) + return EINA_TRUE; + + ERR("Passing Object: %p.", obj); + if (abort_on_warn == -1) + { + if (getenv("ELM_ERROR_ABORT")) abort_on_warn = 1; + else abort_on_warn = 0; + } + if (abort_on_warn == 1) abort(); + return EINA_FALSE; +} + +EAPI Eina_Bool elm_widget_type_check(const Evas_Object *obj, const char *type) { diff --git a/src/lib/elm_widget.h b/src/lib/elm_widget.h index c5eb239..964d061 100644 --- a/src/lib/elm_widget.h +++ b/src/lib/elm_widget.h @@ -403,6 +403,7 @@ EAPI int elm_widget_drag_child_locked_y_get(const Evas_Object *obj) EAPI Eina_Bool elm_widget_theme_object_set(Evas_Object *obj, Evas_Object *edj, const char *wname, const char *welement, const char *wstyle); EAPI void elm_widget_type_register(const char **ptr); EAPI void elm_widget_type_unregister(const char **ptr); +EAPI Eina_Bool elm_widget_is_check(const Evas_Object *obj); EAPI Eina_Bool elm_widget_type_check(const Evas_Object *obj, const char *type); EAPI Eina_List *elm_widget_stringlist_get(const char *str); EAPI void elm_widget_stringlist_free(Eina_List *list); @@ -691,6 +692,9 @@ EAPI void elm_widget_tree_dot_dump(const Evas_Object *top, FILE *out } \ } while (0) +#define ELM_CHECK_WID_IS(obj) \ + if (!elm_widget_is_check(obj)) return + #define ELM_CHECK_WIDTYPE(obj, widtype) \ if (!elm_widget_type_check((obj), (widtype))) return diff --git a/src/lib/els_tooltip.c b/src/lib/els_tooltip.c index 036c8a7..89c041d 100644 --- a/src/lib/els_tooltip.c +++ b/src/lib/els_tooltip.c @@ -738,6 +738,7 @@ elm_object_sub_tooltip_content_cb_set(Evas_Object *eventarea, Evas_Object *owner EAPI void elm_object_tooltip_show(Evas_Object *obj) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj); tt->visible_lock = EINA_TRUE; _elm_tooltip_show(tt); @@ -755,6 +756,7 @@ elm_object_tooltip_show(Evas_Object *obj) EAPI void elm_object_tooltip_hide(Evas_Object *obj) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj); tt->visible_lock = EINA_FALSE; _elm_tooltip_hide_anim_start(tt); @@ -775,6 +777,7 @@ elm_object_tooltip_hide(Evas_Object *obj) EAPI void elm_object_tooltip_text_set(Evas_Object *obj, const char *text) { + ELM_CHECK_WID_IS(obj); EINA_SAFETY_ON_NULL_RETURN(obj); EINA_SAFETY_ON_NULL_RETURN(text); @@ -824,6 +827,7 @@ elm_object_tooltip_domain_translatable_text_set(Evas_Object *obj, const char *do EAPI void elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, const void *data, Evas_Smart_Cb del_cb) { + ELM_CHECK_WID_IS(obj); elm_object_sub_tooltip_content_cb_set(obj, obj, func, data, del_cb); } @@ -843,6 +847,7 @@ elm_object_tooltip_content_cb_set(Evas_Object *obj, Elm_Tooltip_Content_Cb func, EAPI void elm_object_tooltip_unset(Evas_Object *obj) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj); _elm_tooltip_unset(tt); } @@ -860,6 +865,7 @@ elm_object_tooltip_unset(Evas_Object *obj) EAPI void elm_object_tooltip_style_set(Evas_Object *obj, const char *style) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj); if (!eina_stringshare_replace(&tt->style, style)) return; elm_tooltip_theme(tt); @@ -875,6 +881,7 @@ elm_object_tooltip_style_set(Evas_Object *obj, const char *style) EAPI const char * elm_object_tooltip_style_get(const Evas_Object *obj) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj, NULL); return tt->style ? tt->style : "default"; } @@ -922,6 +929,7 @@ elm_tooltip_delay_set(double delay) EAPI Eina_Bool elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE); return tt->free_size = disable; } @@ -938,6 +946,7 @@ elm_tooltip_size_restrict_disable(Evas_Object *obj, Eina_Bool disable) EAPI Eina_Bool elm_tooltip_size_restrict_disabled_get(const Evas_Object *obj) { + ELM_CHECK_WID_IS(obj); ELM_TOOLTIP_GET_OR_RETURN(tt, obj, EINA_FALSE); return tt->free_size; } -- 2.7.4