forked from enlightenment/efl
Eobj: Added event callbacks for Object free/del.
SVN revision: 70231
This commit is contained in:
parent
18258b9002
commit
eb6c52240f
|
@ -441,6 +441,30 @@ EAPI void *eobj_generic_data_get(const Eobj *obj, const char *key);
|
|||
*/
|
||||
EAPI void *eobj_generic_data_del(Eobj *obj, const char *key);
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_FREE
|
||||
* see #EOBJ_EV_FREE
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_FREE;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_FREE
|
||||
* Object is being freed.
|
||||
*/
|
||||
#define EOBJ_EV_FREE (&(_EOBJ_EV_FREE))
|
||||
|
||||
/**
|
||||
* @var _EOBJ_EV_DEL
|
||||
* see #EOBJ_EV_DEL
|
||||
*/
|
||||
EAPI extern const Eobj_Event_Description _EOBJ_EV_DEL;
|
||||
|
||||
/**
|
||||
* @def EOBJ_EV_DEL
|
||||
* Object is being deleted.
|
||||
*/
|
||||
#define EOBJ_EV_DEL (&(_EOBJ_EV_DEL))
|
||||
|
||||
/**
|
||||
* @addtogroup Eobj_Composite_Objects Composite Objects.
|
||||
* @{
|
||||
|
|
|
@ -747,6 +747,18 @@ eobj_unref(Eobj *obj)
|
|||
{
|
||||
if (--(obj->refcount) == 0)
|
||||
{
|
||||
/* We need that for the event callbacks that may ref/unref. */
|
||||
obj->refcount++;
|
||||
|
||||
if (!obj->delete)
|
||||
{
|
||||
eobj_event_callback_call(obj, EOBJ_EV_DEL, NULL);
|
||||
obj->delete = EINA_TRUE;
|
||||
}
|
||||
eobj_event_callback_call(obj, EOBJ_EV_FREE, NULL);
|
||||
|
||||
obj->refcount--;
|
||||
|
||||
const Eobj_Class *klass = eobj_class_get(obj);
|
||||
_eobj_kls_itr_init(obj, EOBJ_NOOP);
|
||||
eobj_constructor_error_unset(obj);
|
||||
|
@ -802,7 +814,11 @@ eobj_ref_get(const Eobj *obj)
|
|||
EAPI void
|
||||
eobj_del(Eobj *obj)
|
||||
{
|
||||
obj->delete = EINA_TRUE;
|
||||
if (!obj->delete)
|
||||
{
|
||||
eobj_event_callback_call(obj, EOBJ_EV_DEL, NULL);
|
||||
obj->delete = EINA_TRUE;
|
||||
}
|
||||
eobj_unref(obj);
|
||||
}
|
||||
|
||||
|
@ -1254,9 +1270,13 @@ static Eobj_Class *_my_class = NULL;
|
|||
|
||||
/* FIXME: Set proper type descriptions. */
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_CALLBACK_ADD =
|
||||
EOBJ_EVENT_DESCRIPTION("callback,add", "?", "Called when a callback was added.");
|
||||
EOBJ_EVENT_DESCRIPTION("callback,add", "?", "A callback was added.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_CALLBACK_DEL =
|
||||
EOBJ_EVENT_DESCRIPTION("callback,del", "?", "Called when a callback was deleted.");
|
||||
EOBJ_EVENT_DESCRIPTION("callback,del", "?", "A callback was deleted.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_FREE =
|
||||
EOBJ_EVENT_DESCRIPTION("free", "", "Obj is being freed.");
|
||||
EAPI const Eobj_Event_Description _EOBJ_EV_DEL =
|
||||
EOBJ_EVENT_DESCRIPTION("del", "", "Obj is being deleted.");
|
||||
|
||||
static void
|
||||
_constructor(Eobj *obj, void *class_data __UNUSED__)
|
||||
|
@ -1278,6 +1298,8 @@ eobj_base_class_get(void)
|
|||
static const Eobj_Event_Description *event_desc[] = {
|
||||
EOBJ_EV_CALLBACK_ADD,
|
||||
EOBJ_EV_CALLBACK_DEL,
|
||||
EOBJ_EV_FREE,
|
||||
EOBJ_EV_DEL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue