eo: add funktion for alive checks
The function simply checks if the object is finalized and not started to be invalidated or invalidated. Differential Revision: https://phab.enlightenment.org/D6723
This commit is contained in:
parent
84973cbbba
commit
068e09cf2e
|
@ -2134,6 +2134,19 @@ eina_value_object_get(Eina_Value *v)
|
|||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get if the object is in its main lifetime.
|
||||
* @param obj the object to check
|
||||
* @return true if the object is finalized, but not invalidating nor invalidated.
|
||||
* @since 1.22
|
||||
*/
|
||||
|
||||
static inline Eina_Bool
|
||||
efl_alive_get(const Eo *obj)
|
||||
{
|
||||
return efl_finalized_get(obj) && !efl_invalidating_get(obj) && !efl_invalidated_get(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Event triggered when a callback was added to the object
|
||||
*/
|
||||
|
|
|
@ -162,7 +162,6 @@ EFL_START_TEST(eo_test_unref_noref)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
|
||||
typedef struct {
|
||||
Eo *par;
|
||||
Eina_Bool called;
|
||||
|
@ -191,6 +190,25 @@ EFL_START_TEST(eo_test_invalidating_get)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
EFL_START_TEST(eo_test_alive_get)
|
||||
{
|
||||
Eina_Bool res;
|
||||
Eo *par = efl_add_ref(SIMPLE_CLASS, NULL);
|
||||
Eo *obj = efl_add(SIMPLE_CLASS, par,
|
||||
res = efl_alive_get(efl_added)
|
||||
);
|
||||
ck_assert_int_eq(res, 0);
|
||||
ck_assert_int_eq(efl_alive_get(obj), 1);
|
||||
efl_ref(obj);
|
||||
ck_assert_int_eq(efl_alive_get(obj), 1);
|
||||
efl_del(obj);
|
||||
ck_assert_int_eq(efl_alive_get(obj), 0);
|
||||
efl_unref(obj);
|
||||
ck_assert_ptr_eq(efl_class_name_get(obj), NULL);
|
||||
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void eo_test_lifecycle(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, eo_test_base_del);
|
||||
|
@ -199,4 +217,5 @@ void eo_test_lifecycle(TCase *tc)
|
|||
tcase_add_test(tc, eo_test_del_in_noref);
|
||||
tcase_add_test(tc, eo_test_unref_noref);
|
||||
tcase_add_test(tc, eo_test_invalidating_get);
|
||||
tcase_add_test(tc, eo_test_alive_get);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue