From 2bbc2e142477008322a33588f20a7cba3050c242 Mon Sep 17 00:00:00 2001 From: Yeongjong Lee Date: Fri, 15 Mar 2019 10:35:17 -0400 Subject: [PATCH] evas_events: prevent double event_freeze in evas_object_freeze_events_set Summary: This patch prevent that event_freeze_count is greater than 1 in `evas_object_freeze_events_set` Test Plan: make check Reviewers: bu5hm4n, zmike Reviewed By: zmike Subscribers: zmike, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8325 Change-Id: Ia8474fd064a83f7824c985269f32116954189968 --- src/lib/evas/canvas/evas_events.c | 6 ++++++ src/tests/evas/evas_test_object.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/lib/evas/canvas/evas_events.c b/src/lib/evas/canvas/evas_events.c index 28740d2..c1839b6 100644 --- a/src/lib/evas/canvas/evas_events.c +++ b/src/lib/evas/canvas/evas_events.c @@ -3880,6 +3880,12 @@ _efl_canvas_object_efl_object_event_thaw(Eo *obj, Evas_Object_Protected_Data *pd EAPI void evas_object_freeze_events_set(Eo *eo_obj, Eina_Bool freeze) { + Evas_Object_Protected_Data *pd = EVAS_OBJECT_DATA_SAFE_GET(eo_obj); + EINA_SAFETY_ON_NULL_RETURN(pd); + + freeze = !!freeze; + if (pd->freeze_events == freeze) return; + if (freeze) efl_event_freeze(eo_obj); else diff --git a/src/tests/evas/evas_test_object.c b/src/tests/evas/evas_test_object.c index ac4424e..d2de52a 100644 --- a/src/tests/evas/evas_test_object.c +++ b/src/tests/evas/evas_test_object.c @@ -30,7 +30,29 @@ EFL_START_TEST(evas_object_various) } EFL_END_TEST +EFL_START_TEST(evas_object_freeze_events) +{ + Evas *evas = EVAS_TEST_INIT_EVAS(); + Evas_Object *obj = evas_object_rectangle_add(evas); + + evas_object_freeze_events_set(obj, EINA_TRUE); + ck_assert_int_eq(evas_object_freeze_events_get(obj), EINA_TRUE); + evas_object_freeze_events_set(obj, EINA_FALSE); + ck_assert_int_eq(evas_object_freeze_events_get(obj), EINA_FALSE); + + evas_object_freeze_events_set(obj, EINA_TRUE); + evas_object_freeze_events_set(obj, EINA_TRUE); + ck_assert_int_eq(evas_object_freeze_events_get(obj), EINA_TRUE); + evas_object_freeze_events_set(obj, EINA_FALSE); + ck_assert_int_eq(evas_object_freeze_events_get(obj), EINA_FALSE); + evas_object_freeze_events_set(obj, EINA_FALSE); + evas_object_freeze_events_set(obj, EINA_TRUE); + ck_assert_int_eq(evas_object_freeze_events_get(obj), EINA_TRUE); +} +EFL_END_TEST + void evas_test_object(TCase *tc) { tcase_add_test(tc, evas_object_various); + tcase_add_test(tc, evas_object_freeze_events); } -- 2.7.4