ecore/edje/elm: Fix a few WRN from calls to NULL

This fixes some of the warnings generated by calling functions on NULL
objects. One of the main remaining points is to avoid unwanted warnings
on non-existing parts.

Ref T6326
This commit is contained in:
Jean-Philippe Andre 2018-01-16 15:12:49 +09:00
parent f2b5b00ca2
commit a92186be6a
17 changed files with 105 additions and 56 deletions

View File

@ -417,12 +417,12 @@ static Eina_Bool
_ecore_event_evas_key(Ecore_Event_Key *e, Ecore_Event_Press press)
{
Ecore_Input_Window *lookup;
Eo *seat;
lookup = _ecore_event_window_match(e->event_window);
if (!lookup) return ECORE_CALLBACK_PASS_ON;
ecore_event_evas_seat_modifier_lock_update(lookup->evas,
e->modifiers,
efl_input_device_seat_get(e->dev));
seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
if (press == ECORE_DOWN)
{
if (!lookup->direct ||
@ -531,9 +531,8 @@ _ecore_event_evas_mouse_button(Ecore_Event_Mouse_Button *e, Ecore_Event_Press pr
if (e->multi.device == 0)
{
ecore_event_evas_seat_modifier_lock_update(lookup->evas,
e->modifiers,
efl_input_device_seat_get(e->dev));
Eo *seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
if (press == ECORE_DOWN)
{
if (!lookup->direct ||
@ -612,10 +611,9 @@ ecore_event_evas_mouse_move(void *data EINA_UNUSED, int type EINA_UNUSED, void *
if (!lookup) return ECORE_CALLBACK_PASS_ON;
if (e->multi.device == 0)
{
Eo *seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
_ecore_event_evas_push_mouse_move(e);
ecore_event_evas_seat_modifier_lock_update(lookup->evas,
e->modifiers,
efl_input_device_seat_get(e->dev));
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
if (!lookup->direct ||
!lookup->direct(lookup->window, ECORE_EVENT_MOUSE_MOVE, e))
{
@ -671,12 +669,13 @@ static Eina_Bool
_ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io)
{
Ecore_Input_Window *lookup;
Eo *seat;
lookup = _ecore_event_window_match(e->event_window);
if (!lookup) return ECORE_CALLBACK_PASS_ON;
ecore_event_evas_seat_modifier_lock_update(lookup->evas,
e->modifiers,
efl_input_device_seat_get(e->dev));
seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
switch (io)
{
case ECORE_IN:
@ -718,12 +717,13 @@ ecore_event_evas_mouse_wheel(void *data EINA_UNUSED, int type EINA_UNUSED, void
{
Ecore_Event_Mouse_Wheel *e;
Ecore_Input_Window *lookup;
Eo *seat;
e = event;
lookup = _ecore_event_window_match(e->event_window);
if (!lookup) return ECORE_CALLBACK_PASS_ON;
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers,
efl_input_device_seat_get(e->dev));
seat = e->dev ? efl_input_device_seat_get(e->dev) : NULL;
ecore_event_evas_seat_modifier_lock_update(lookup->evas, e->modifiers, seat);
if (!lookup->direct ||
!lookup->direct(lookup->window, ECORE_EVENT_MOUSE_WHEEL, e))
{

View File

@ -1083,7 +1083,8 @@ _edje_dragable_pos_set(Edje *ed, Edje_Real_Part *ep, FLOAT_T x, FLOAT_T y)
* value we would set foo to, because it would depend on the
* size of the dragable...
*/
evas_object_geometry_get(ep->object, &ex, &ey, NULL, NULL);
if (ep->object)
evas_object_geometry_get(ep->object, &ex, &ey, NULL, NULL);
if (NEQ(ep->drag->x, x) || ep->drag->tmp.x)
{

View File

@ -182,13 +182,21 @@ _efl_canvas_layout_efl_gfx_position_set(Eo *obj, Edje *ed, Eina_Position2D pos)
ep = ed->table_parts[i];
if ((ep->type == EDJE_RP_TYPE_TEXT) && (ep->typedata.text))
{
evas_object_move(ep->object,
ed->x + ep->x + ep->typedata.text->offset.x,
ed->y + ep->y + ep->typedata.text->offset.y);
if (ep->object)
evas_object_move(ep->object,
ed->x + ep->x + ep->typedata.text->offset.x,
ed->y + ep->y + ep->typedata.text->offset.y);
else if (ep->type != EFL_CANVAS_LAYOUT_PART_TYPE_NONE)
WRN("No object for part '%s' in group '%s'",
ep->part ? ep->part->name : "<invalid>", ed->group);
}
else
{
evas_object_move(ep->object, ed->x + ep->x, ed->y + ep->y);
if (ep->object)
evas_object_move(ep->object, ed->x + ep->x, ed->y + ep->y);
else if (ep->type != EFL_CANVAS_LAYOUT_PART_TYPE_NONE)
WRN("No object for part '%s' in group '%s'",
ep->part ? ep->part->name : "<invalid>", ed->group);
if ((ep->type == EDJE_RP_TYPE_SWALLOW) &&
(ep->typedata.swallow))
{

View File

@ -3297,7 +3297,11 @@ _efl_canvas_layout_efl_part_part(Eo *obj, Edje *ed, const char *part)
if ((!ed) || (!part)) return NULL;
rp = _edje_real_part_recursive_get(&ed, part);
if (!rp) return NULL;
if (EINA_UNLIKELY(!rp))
{
WRN("No such part '%s' in group '%s'.", part, ed->group);
return NULL;
}
if (rp->part->type == EDJE_PART_TYPE_BOX)
return _edje_box_internal_proxy_get(obj, ed, rp);

View File

@ -109,6 +109,7 @@ _icon_signal_emit(Evas_Object *obj)
{
char buf[64];
if (!elm_widget_resize_object_get(obj)) return;
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");

View File

@ -93,6 +93,7 @@ _icon_signal_emit(Evas_Object *obj)
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
char buf[64];
if (!elm_widget_resize_object_get(obj)) return;
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");

View File

@ -81,6 +81,8 @@ typedef struct {
static void
_manager_in_chain_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
{
Eo *manager;
EINA_SAFETY_ON_NULL_RETURN(pd->root);
if (!efl_isa(pd->root->focusable, EFL_UI_WIN_CLASS))
@ -89,7 +91,12 @@ _manager_in_chain_set(Eo *obj, Efl_Ui_Focus_Manager_Calc_Data *pd)
//so we dont run infinitly this does not fix it, but at least we only have a error
EINA_SAFETY_ON_TRUE_RETURN(efl_ui_focus_user_focus_manager_get(pd->root->focusable) == obj);
efl_ui_focus_manager_focus_set(efl_ui_focus_user_focus_manager_get(pd->root->focusable), pd->root->focusable);
manager = efl_ui_focus_user_focus_manager_get(pd->root->focusable);
if (manager)
efl_ui_focus_manager_focus_set(manager, pd->root->focusable);
else
DBG("No focus manager for focusable %s@%p",
efl_class_name_get(pd->root->focusable), pd->root->focusable);
}
static Efl_Ui_Focus_Direction
@ -1569,8 +1576,10 @@ _efl_ui_focus_manager_calc_efl_ui_focus_manager_manager_focus_set(Eo *obj, Efl_U
if (node_type == NODE_TYPE_NORMAL)
{
//populate the new change
efl_ui_focus_object_focus_set(last_focusable, EINA_FALSE);
efl_ui_focus_object_focus_set(new_focusable, EINA_TRUE);
if (last_focusable)
efl_ui_focus_object_focus_set(last_focusable, EINA_FALSE);
if (new_focusable)
efl_ui_focus_object_focus_set(new_focusable, EINA_TRUE);
efl_event_callback_call(obj, EFL_UI_FOCUS_MANAGER_EVENT_FOCUSED, last_focusable);
}

View File

@ -137,10 +137,10 @@ _logical_manager_change(void *data EINA_UNUSED, const Efl_Event *ev)
Eina_List *n;
Efl_Ui_Focus_User *b;
Efl_Ui_Focus_Manager *manager;
manager = efl_ui_focus_user_focus_manager_get(ev->object);
if (!ev->info) return;
manager = efl_ui_focus_user_focus_manager_get(ev->object);
EINA_LIST_FOREACH(pd->current_border, n, b)
{
if (b == ev->object) continue;
@ -156,13 +156,12 @@ _flush_manager(Eo *obj, Efl_Ui_Focus_Manager_Sub_Data *pd)
Efl_Ui_Focus_User *b;
Eina_List *n;
logical = efl_ui_focus_user_focus_parent_get(obj);
manager = efl_ui_focus_user_focus_manager_get(obj);
//unregister from the old
efl_event_callback_array_del(pd->manager, parent_manager(), obj);
efl_event_callback_array_add(manager, parent_manager(), obj);
if (pd->manager) efl_event_callback_array_del(pd->manager, parent_manager(), obj);
if (manager) efl_event_callback_array_add(manager, parent_manager(), obj);
EINA_LIST_FOREACH(pd->current_border , n, b)
{
@ -203,7 +202,7 @@ _efl_ui_focus_manager_sub_efl_object_destructor(Eo *obj, Efl_Ui_Focus_Manager_Su
{
_border_unregister(obj, pd);
efl_event_callback_array_del(pd->manager, parent_manager(), obj);
if (pd->manager) efl_event_callback_array_del(pd->manager, parent_manager(), obj);
efl_destructor(efl_super(obj, MY_CLASS));
}

View File

@ -25,7 +25,7 @@ _efl_ui_focus_util_focus(Eo *obj EINA_UNUSED, void *pd EINA_UNUSED, Efl_Ui_Focus
top = elm_widget_top_get(user);
o = efl_key_data_get(top, "__delayed_focus_set");
efl_event_callback_del(o, EFL_UI_FOCUS_USER_EVENT_MANAGER_CHANGED, _manager_changed, o);
if (o) efl_event_callback_del(o, EFL_UI_FOCUS_USER_EVENT_MANAGER_CHANGED, _manager_changed, o);
efl_key_data_set(top, "__delayed_focus_set", NULL);
if (!m)

View File

@ -165,8 +165,12 @@ _icon_signal_emit(Efl_Ui_Layout_Data *sd,
{
char buf[1024];
const char *type;
Eo *edje;
int i;
edje = elm_widget_resize_object_get(sd->obj);
if (!edje) return;
//FIXME: Don't limit to the icon and end here.
// send signals for all contents after elm 2.0
if (sub_d->type != SWALLOW) return;
@ -184,11 +188,10 @@ _icon_signal_emit(Efl_Ui_Layout_Data *sd,
snprintf(buf, sizeof(buf), "elm,state,%s,%s", type,
visible ? "visible" : "hidden");
ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
edje_object_signal_emit(wd->resize_obj, buf, "elm");
edje_object_signal_emit(edje, buf, "elm");
/* themes might need immediate action here */
edje_object_message_signal_process(wd->resize_obj);
edje_object_message_signal_process(edje);
}
static inline void
@ -640,17 +643,14 @@ _efl_ui_layout_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Layout_Data *sd)
Efl_Ui_Layout_Sub_Connect *sc;
Edje_Signal_Data *esd;
Evas_Object *child;
Eina_List *l;
Eina_List *l, *ll;
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
elm_layout_freeze(obj);
EINA_LIST_FREE(sd->subs, sub_d)
{
eina_stringshare_del(sub_d->part);
free(sub_d);
}
EINA_LIST_FOREACH_SAFE(sd->subs, l, ll, sub_d)
efl_ui_widget_sub_object_del(obj, sub_d->obj);
EINA_LIST_FREE(sd->parts_cursors, pc)
_part_cursor_free(pc);
@ -2430,17 +2430,18 @@ elm_layout_theme_set(Evas_Object *obj, const char *klass, const char *group, con
EOLIAN static Eo *
_efl_ui_layout_efl_part_part(const Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED, const char *part)
{
Efl_Canvas_Layout_Part_Type type;
Efl_Canvas_Layout_Part_Type type = EFL_CANVAS_LAYOUT_PART_TYPE_NONE;
EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
ELM_WIDGET_DATA_GET_OR_RETURN((Eo *) obj, wd, NULL);
// Check part type without using edje_object_part_object_get(), as this
// can cause recalc, which has side effects... and could be slow.
type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, part));
if (eina_streq(part, "background"))
{
if (efl_layout_group_part_exist_get(wd->resize_obj, part))
type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, part));
if (type != EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW)
{
if (type < EFL_CANVAS_LAYOUT_PART_TYPE_LAST &&
@ -2459,9 +2460,18 @@ _efl_ui_layout_efl_part_part(const Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED,
else if (eina_streq(part, "shadow"))
return efl_part(efl_super(obj, MY_CLASS), part);
if (!efl_layout_group_part_exist_get(wd->resize_obj, part))
{
WRN("No such part '%s' in group '%s'",
part, elm_widget_theme_element_get(obj));
return NULL;
}
type = efl_canvas_layout_part_type_get(efl_part(wd->resize_obj, part));
if (type >= EFL_CANVAS_LAYOUT_PART_TYPE_LAST)
{
ERR("Invalid type found for part '%s' in group '%s'", part, elm_widget_theme_element_get(obj));
ERR("Invalid type found for part '%s' in group '%s'",
part, elm_widget_theme_element_get(obj));
return NULL;
}
@ -2475,9 +2485,6 @@ _efl_ui_layout_efl_part_part(const Eo *obj, Efl_Ui_Layout_Data *sd EINA_UNUSED,
return ELM_PART_IMPLEMENT(EFL_UI_LAYOUT_PART_TEXT_CLASS, obj, part);
case EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW:
return ELM_PART_IMPLEMENT(EFL_UI_LAYOUT_PART_CONTENT_CLASS, obj, part);
case EFL_CANVAS_LAYOUT_PART_TYPE_NONE:
WRN("No such part '%s' in group '%s'", part, elm_widget_theme_element_get(obj));
return NULL;
default:
return ELM_PART_IMPLEMENT(EFL_UI_LAYOUT_PART_CLASS, obj, part);
}

View File

@ -172,6 +172,7 @@ _icon_signal_emit(Evas_Object *obj)
{
char buf[64];
if (!elm_widget_resize_object_get(obj)) return;
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");

View File

@ -137,14 +137,16 @@ _key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
static void
_icon_signal_emit(Evas_Object *obj)
{
ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
char buf[64];
Eo *edje;
edje = elm_widget_resize_object_get(obj);
if (!edje) return;
snprintf(buf, sizeof(buf), "elm,state,icon,%s",
elm_layout_content_get(obj, "icon") ? "visible" : "hidden");
elm_layout_signal_emit(obj, buf, "elm");
edje_object_message_signal_process(wd->resize_obj);
edje_object_message_signal_process(edje);
}
EOLIAN static Efl_Ui_Theme_Apply

View File

@ -311,7 +311,7 @@ _focus_manager_eval(Eo *obj, Elm_Widget_Smart_Data *pd)
{
new = parent;
}
else
else if (parent)
{
new = efl_ui_focus_user_focus_manager_get(parent);
provider = parent;
@ -358,10 +358,11 @@ _efl_ui_widget_focus_state_apply(Eo *obj, Elm_Widget_Smart_Data *pd EINA_UNUSED,
if (!current_state.manager) registered = EINA_FALSE;
if (//check if we have changed the manager
(current_state.manager != configured_state->manager) ||
//check if we are already registered but in a different state
(current_state.logical != configured_state->logical))
if ((//check if we have changed the manager
(current_state.manager != configured_state->manager) ||
//check if we are already registered but in a different state
(current_state.logical != configured_state->logical))
&& registered)
{
//we need to unregister here
efl_ui_focus_manager_calc_unregister(current_state.manager, obj);
@ -2439,10 +2440,14 @@ _efl_ui_widget_disabled_set(Eo *obj, Elm_Widget_Smart_Data *sd, Eina_Bool disabl
}
EOLIAN static Eina_Bool
_efl_ui_widget_disabled_get(Eo *obj EINA_UNUSED, Elm_Widget_Smart_Data *sd)
_efl_ui_widget_disabled_get(Eo *obj, Elm_Widget_Smart_Data *sd)
{
Eo *parent;
if (sd->disabled) return EINA_TRUE;
return elm_widget_disabled_get(elm_widget_parent_get(obj));
if ((parent = elm_widget_parent_get(obj)) != NULL)
return elm_widget_disabled_get(parent);
return EINA_FALSE;
}
EOLIAN static void
@ -5480,7 +5485,7 @@ _efl_ui_widget_efl_object_provider_find(const Eo *obj, Elm_Widget_Smart_Data *pd
if (pd->provider_lookup) return NULL;
pd->provider_lookup = EINA_TRUE;
lookup = efl_provider_find(pd->parent_obj, klass);
if (pd->parent_obj) lookup = efl_provider_find(pd->parent_obj, klass);
if (!lookup) lookup = efl_provider_find(efl_super(obj, MY_CLASS), klass);
pd->provider_lookup = EINA_FALSE;

View File

@ -1295,7 +1295,8 @@ _elm_entry_focus_update(Eo *obj, Elm_Entry_Data *sd)
edje_object_part_text_select_none(sd->entry_edje, "elm.text");
}
}
edje_object_signal_emit(sd->scr_edje, "validation,default", "elm");
if (sd->scr_edje)
edje_object_signal_emit(sd->scr_edje, "validation,default", "elm");
}
}

View File

@ -82,7 +82,8 @@ _round(double value, int pos)
static void
_elm_pan_update(Elm_Pan_Smart_Data *psd)
{
evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
if (psd->content)
evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
}
EOLIAN static void

View File

@ -830,6 +830,13 @@ EAPI extern Eina_Bool _elm_legacy_add;
#define elm_legacy_add(k, p, ...) ({ _elm_legacy_add = 1; \
efl_add(k, p, efl_canvas_object_legacy_ctor(efl_added), ##__VA_ARGS__); })
static inline Eo *
elm_widget_resize_object_get(const Eo *obj)
{
Elm_Widget_Smart_Data *wd = efl_data_scope_safe_get(obj, EFL_UI_WIDGET_CLASS);
return wd ? wd->resize_obj : NULL;
}
static inline Eina_Bool
elm_widget_is_legacy(const Eo *obj)
{

View File

@ -212,6 +212,8 @@ _elm_cursor_set_hot_spots(Elm_Cursor *cur)
Evas_Coord cx, cy, cw, ch, x, y, w, h;
int prev_hot_x, prev_hot_y;
if (!cur->visible) return;
prev_hot_x = cur->hot_x;
prev_hot_y = cur->hot_y;