evas_events: prevent double event_freeze in evas_object_freeze_events_set 76/201876/1
authorYeongjong Lee <yj34.lee@samsung.com>
Fri, 15 Mar 2019 14:35:17 +0000 (10:35 -0400)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 20 Mar 2019 11:16:59 +0000 (20:16 +0900)
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
src/tests/evas/evas_test_object.c

index 28740d2..c1839b6 100644 (file)
@@ -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
index ac4424e..d2de52a 100644 (file)
@@ -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);
 }