Merge branch 'devs/iscaro/devices'

Series of fixes regarding Efl.Input.Device references.
There were some issues on Evas and on its own interface.

Also adds efl_replace() to replace referenced objects
(using it for devices for now). It follows
eina_stringshare_replace() approach.

Patches by Guilherme Iscaro <iscaro@profusion.mobi>
Differential Revision: https://phab.enlightenment.org/D4445
This commit is contained in:
Bruno Dilly 2016-12-02 15:27:05 -02:00
commit 81a25bc83f
6 changed files with 34 additions and 10 deletions

View File

@ -28,7 +28,11 @@ _efl_input_device_efl_object_destructor(Eo *obj, Efl_Input_Device_Data *pd)
{
Efl_Input_Device_Data *child = efl_data_scope_get(eo_child, EFL_INPUT_DEVICE_CLASS);
child->parent = NULL;
efl_unref(eo_child);
}
if (pd->parent)
{
Efl_Input_Device_Data *p = efl_data_scope_get(pd->parent, EFL_INPUT_DEVICE_CLASS);
p->children = eina_list_remove(p->children, obj);
}
efl_unref(pd->source);
@ -128,14 +132,12 @@ _efl_input_device_parent_set(Eo *obj, Efl_Input_Device_Data *pd, Efl_Input_Devic
{
Efl_Input_Device_Data *p = efl_data_scope_get(pd->parent, EFL_INPUT_DEVICE_CLASS);
p->children = eina_list_remove(p->children, obj);
efl_unref(obj);
}
pd->parent = parent;
if (parent)
{
Efl_Input_Device_Data *p = efl_data_scope_get(parent, EFL_INPUT_DEVICE_CLASS);
p->children = eina_list_append(p->children, obj);
efl_ref(obj);
}
}

View File

@ -1333,6 +1333,28 @@ EAPI int efl_callbacks_cmp(const Efl_Callback_Array_Item *a, const Efl_Callback_
efl_event_callback_array_priority_add(obj, array, \
EFL_CALLBACK_PRIORITY_DEFAULT, data)
/**
* @def Replace the previously Eo pointer with new content.
*
* @param storage The object to replace the old reference. It can not be @c NULL.
* @param new_obj The new object. It may be @c NULL.
*
* The string pointed by @c storage must be previously an Eo or
* @c NULL and it will be efl_unref(). The @a new_obj will be passed
* to efl_ref() and then assigned to @c *storage.
*
* @see efl_ref()
* @see efl_unref()
*/
static inline void
efl_replace(Eo **storage, Eo *new_obj)
{
if (!storage || *storage == new_obj) return;
efl_ref(new_obj);
efl_unref(*storage);
*storage = new_obj;
}
/**
* @}
*/

View File

@ -25,6 +25,7 @@ _del_hook(Eo *evt)
}
efl_reuse(evt);
s_cached_event = evt;
efl_input_reset(s_cached_event);
}
else
{
@ -82,7 +83,7 @@ _efl_input_focus_efl_input_event_device_set(Eo *obj EINA_UNUSED,
Efl_Input_Focus_Data *pd,
Efl_Input_Device *device)
{
pd->device = efl_ref(device);
efl_replace(&pd->device, device);
}
EOLIAN static Efl_Input_Device *
@ -136,7 +137,6 @@ _efl_input_focus_efl_input_event_instance_get(Eo *klass EINA_UNUSED, void *_pd E
{
evt = s_cached_event;
s_cached_event = NULL;
efl_input_reset(evt);
efl_parent_set(evt, owner);
}
else

View File

@ -26,7 +26,7 @@ _efl_input_hold_hold_get(Eo *obj EINA_UNUSED, Efl_Input_Hold_Data *pd)
EOLIAN static void
_efl_input_hold_efl_input_event_device_set(Eo *obj EINA_UNUSED, Efl_Input_Hold_Data *pd, Efl_Input_Device *dev)
{
pd->device = efl_ref(dev);
efl_replace(&pd->device, dev);
}
EOLIAN static Efl_Input_Device *

View File

@ -25,6 +25,7 @@ _del_hook(Eo *evt)
}
efl_reuse(evt);
s_cached_event = evt;
efl_input_reset(s_cached_event);
}
else
{
@ -44,7 +45,6 @@ _efl_input_key_efl_input_event_instance_get(Eo *klass EINA_UNUSED, void *_pd EIN
{
evt = s_cached_event;
s_cached_event = NULL;
efl_input_reset(evt);
efl_parent_set(evt, owner);
}
else
@ -230,7 +230,7 @@ _efl_input_key_efl_input_event_event_flags_get(Eo *obj EINA_UNUSED, Efl_Input_Ke
EOLIAN static void
_efl_input_key_efl_input_event_device_set(Eo *obj EINA_UNUSED, Efl_Input_Key_Data *pd, Efl_Input_Device *dev)
{
pd->device = efl_ref(dev);
efl_replace(&pd->device, dev);
}
EOLIAN static Efl_Input_Device *

View File

@ -36,6 +36,7 @@ _del_hook(Eo *evt)
}
efl_reuse(evt);
s_cached_event = evt;
efl_input_reset(s_cached_event);
}
else
{
@ -55,7 +56,6 @@ _efl_input_pointer_efl_input_event_instance_get(Eo *klass EINA_UNUSED, void *_pd
{
evt = s_cached_event;
s_cached_event = NULL;
efl_input_reset(evt);
efl_parent_set(evt, owner);
}
else
@ -224,7 +224,7 @@ _efl_input_pointer_delta_get(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, in
EOLIAN static void
_efl_input_pointer_efl_input_event_device_set(Eo *obj EINA_UNUSED, Efl_Input_Pointer_Data *pd, Efl_Input_Device *dev)
{
pd->device = efl_ref(dev);
efl_replace(&pd->device, dev);
}
EOLIAN static Efl_Input_Device *