From 365c0334ff66af2592c8f86f542024d0b506ca3e Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Mon, 20 Aug 2018 13:15:56 -0400 Subject: [PATCH] efl_object: add call for getting invalidating Summary: there is now invalidated & invalidating. invalidated returns true when all children are invalidated, and the object is / was requested to be invalidated. invalidating return true when the object is called to be invalidated but not all children are invalidated yet. However, the object is garanteed to be invalidated in near future. Reviewers: zmike Reviewed By: zmike Subscribers: cedric Tags: #efl, #do_not_merge Differential Revision: https://phab.enlightenment.org/D6722 --- src/lib/eo/efl_object.eo | 11 ++++++++++ src/lib/eo/eo_base_class.c | 10 +++++++++ src/tests/eo/suite/eo_test_lifecycle.c | 30 ++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/lib/eo/efl_object.eo b/src/lib/eo/efl_object.eo index 97a9489c30..a0d500bfea 100644 --- a/src/lib/eo/efl_object.eo +++ b/src/lib/eo/efl_object.eo @@ -129,6 +129,17 @@ abstract Efl.Object () finalized: bool; [[$true if the object is invalidated, $false otherwise]] } } + @property invalidating { + [[True if the object is about to be invalidated, and the invalidation of the children is already happening. + + Note this is true before the invalidate call on the object. + ]] + get { + } + values { + invalidating: bool; [[$true if the object is invalidating, $false otherwise]] + } + } provider_find @const { [[Searches upwards in the object tree for a provider which knows the given class/interface. diff --git a/src/lib/eo/eo_base_class.c b/src/lib/eo/eo_base_class.c index 5acc70bca2..b2de426e37 100644 --- a/src/lib/eo/eo_base_class.c +++ b/src/lib/eo/eo_base_class.c @@ -827,6 +827,16 @@ _efl_object_invalidated_get(const Eo *obj_id, Efl_Object_Data *pd) return invalidate; } +EOLIAN static Eina_Bool +_efl_object_invalidating_get(const Eo *obj_id, Efl_Object_Data *pd EINA_UNUSED) +{ + Eina_Bool invalidating; + EO_OBJ_POINTER_RETURN_VAL(obj_id, obj, EINA_TRUE); + invalidating = obj->is_invalidating; + EO_OBJ_DONE(obj_id); + return invalidating; +} + EOLIAN static Efl_Object * _efl_object_provider_find(const Eo *obj, Efl_Object_Data *pd, const Efl_Object *klass) { diff --git a/src/tests/eo/suite/eo_test_lifecycle.c b/src/tests/eo/suite/eo_test_lifecycle.c index b0c67bca45..190a7366ca 100644 --- a/src/tests/eo/suite/eo_test_lifecycle.c +++ b/src/tests/eo/suite/eo_test_lifecycle.c @@ -162,6 +162,35 @@ EFL_START_TEST(eo_test_unref_noref) } EFL_END_TEST + +typedef struct { + Eo *par; + Eina_Bool called; +} Invalidating_Test_Helper; + +static void +_invalidate2(void *data, const Efl_Event *ev EINA_UNUSED) +{ + Invalidating_Test_Helper *iev = data; + + iev->called = EINA_TRUE; + ck_assert_int_eq(efl_invalidating_get(iev->par), EINA_TRUE); + ck_assert_int_eq(efl_invalidated_get(iev->par), EINA_FALSE); +} + +EFL_START_TEST(eo_test_invalidating_get) +{ + Eo *par = efl_add_ref(SIMPLE_CLASS, NULL); + Eo *obj = efl_add(SIMPLE_CLASS, par); + Invalidating_Test_Helper data = {par, EINA_FALSE}; + + efl_event_callback_add(obj, EFL_EVENT_INVALIDATE, _invalidate2, &data); + + efl_unref(par); + ck_assert_int_eq(data.called, EINA_TRUE); +} +EFL_END_TEST + void eo_test_lifecycle(TCase *tc) { tcase_add_test(tc, eo_test_base_del); @@ -169,4 +198,5 @@ void eo_test_lifecycle(TCase *tc) tcase_add_test(tc, eo_test_shutdown_eventting); 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); }