elementary: Check for valid cursor_rect when (un)setting focus

Summary:
As the cursor_rect for elm_code_widget is not created until the code
widget gets focus, we cannot just assume it is already there when
trying to emit a focus signal. The cursor_rect does not get created
until widget_cursor_update is called.

This fixes an issue where NULL is passed to efl_layout_signal_emit.

To test this, just launch elementary_test and click the Code Editor
test. As soon as you try to click into the Code Editor, this gets
triggered.

ref T7030

Reviewers: netstar, ajwillia.ms

Reviewed By: netstar

Subscribers: #reviewers, cedric, #committers, zmike

Tags: #efl

Maniphest Tasks: T7030

Differential Revision: https://phab.enlightenment.org/D6701
This commit is contained in:
Chris Michael 2018-08-14 15:45:30 +01:00 committed by Alastair Poole
parent 59b8a63d65
commit 6119cc0c65
1 changed files with 4 additions and 2 deletions

View File

@ -1833,7 +1833,8 @@ _elm_code_widget_focused_event_cb(void *data, Evas_Object *obj,
pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
pd->focussed = EINA_TRUE;
elm_layout_signal_emit(pd->cursor_rect, "elm,action,focus", "elm");
if (pd->cursor_rect)
elm_layout_signal_emit(pd->cursor_rect, "elm,action,focus", "elm");
_elm_code_widget_refresh(obj, NULL);
}
@ -1849,7 +1850,8 @@ _elm_code_widget_unfocused_event_cb(void *data, Evas_Object *obj,
pd = efl_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
pd->focussed = EINA_FALSE;
elm_layout_signal_emit(pd->cursor_rect, "elm,action,unfocus", "elm");
if (pd->cursor_rect)
elm_layout_signal_emit(pd->cursor_rect, "elm,action,unfocus", "elm");
_elm_code_widget_refresh(obj, NULL);
}