diff options
author | Lauro Moura <lauromoura@expertisesolutions.com.br> | 2019-08-14 18:45:38 +0000 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2019-08-14 12:08:19 -0700 |
commit | 252f0c42a07b23e21f9fbe7153895d9b92be0cae (patch) | |
tree | baf4dc7faf887679e27be5a1b755cf455e503900 | |
parent | d672d55107efba803c928a55252ab00afe2d0ba3 (diff) | |
download | efl-252f0c42a07b23e21f9fbe7153895d9b92be0cae.tar.gz |
elementary: Avoid segfault when part is not set.
Check whether we called `efl_part_get` before.
This was happening to C# bindings (maybe a bug there?) but in any case a
failure is safer than a segfault.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D9563
-rw-r--r-- | src/lib/elementary/efl_ui_widget_factory.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/lib/elementary/efl_ui_widget_factory.c b/src/lib/elementary/efl_ui_widget_factory.c index da83117007..371b81984e 100644 --- a/src/lib/elementary/efl_ui_widget_factory.c +++ b/src/lib/elementary/efl_ui_widget_factory.c @@ -189,7 +189,7 @@ _efl_ui_widget_factory_efl_part_part_get(const Eo *obj, part = efl_add(EFL_UI_PROPERTY_BIND_PART_CLASS, (Eo*) obj); if (!part) return NULL; - ppd = efl_data_scope_get(obj, EFL_UI_PROPERTY_BIND_PART_CLASS); + ppd = efl_data_scope_get(part, EFL_UI_PROPERTY_BIND_PART_CLASS); ppd->name = eina_stringshare_add(name); ppd->pd = pd; @@ -213,6 +213,12 @@ _efl_ui_property_bind_part_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSE Efl_Ui_Bind_Part_Data *bpd; Efl_Ui_Property_Bind_Data *bppd; + if (!pd->pd) + { + EINA_LOG_ERR("Trying to bind part property without specifying which part"); + return ENOENT; + } + if (!pd->pd->parts) pd->pd->parts = eina_hash_stringshared_new(NULL); @@ -228,13 +234,15 @@ _efl_ui_property_bind_part_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSE } bppd = calloc(1, sizeof (Efl_Ui_Property_Bind_Data)); - if (bppd) return ENOMEM; + if (!bppd) return ENOMEM; bppd->part_property = eina_stringshare_add(key); bppd->model_property = eina_stringshare_add(property); bpd->properties = eina_list_append(bpd->properties, bppd); + efl_event_callback_call(obj, EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND, (void*) key); + return 0; } |