efl_datetime_manager: how did that ever work?
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Mon, 9 Dec 2019 18:25:18 +0000 (19:25 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Mon, 16 Dec 2019 03:26:45 +0000 (12:26 +0900)
seriously, it sometimes might be worth at least *reading* what code
does, this was initializating a private data struct on one single global
boolean flag. How was that ever intended to work ? How could that ever
slip through review ?

This is not the only madness in these widget arround time and date, you
cannot even select hours in 24h mode, you also cannot cannot select the
0 hour, which is kind of normal for the one or another region? the
datetimemanager (which is IMO a complete misconcept) is full of FIXMEs
and API calls that are defined and never called at all. Again what is
this ? And how did that ever get into the codebase ?!

With this commit the widget *finally* can be created more than once
without exploding and erroring one.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10843

src/lib/elementary/efl_datetime_manager.c
src/tests/elementary/spec/efl_test_basics.c

index 24daa34..7445b8c 100644 (file)
@@ -22,10 +22,9 @@ typedef struct
 {
    Efl_Time time;
    char format[MAX_FORMAT_LEN];
+   Eina_Bool init;
 } Efl_Datetime_Manager_Data;
 
-Eina_Bool init = EINA_FALSE;
-
 static void
 _time_init(Efl_Time *curr_time)
 {
@@ -33,8 +32,6 @@ _time_init(Efl_Time *curr_time)
 
    t = time(NULL);
    localtime_r(&t, curr_time);
-
-   init = EINA_TRUE;
 }
 
 static char *
@@ -162,7 +159,8 @@ _efl_datetime_manager_value_set(Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *
 EOLIAN static Efl_Time
 _efl_datetime_manager_value_get(const Eo *obj EINA_UNUSED, Efl_Datetime_Manager_Data *pd)
 {
-   if (!init) _time_init(&pd->time);
+   if (!pd->init) _time_init(&pd->time);
+   pd->init = EINA_TRUE;
 
    return pd->time;
 }
index 99a441c..b14e18a 100644 (file)
@@ -124,6 +124,13 @@ EFL_START_TEST(no_leaking_canvas_object)
 }
 EFL_END_TEST
 
+
+EFL_START_TEST(no_err_on_creation)
+{
+   widget = efl_add(widget_klass, win);
+}
+EFL_END_TEST
+
 EFL_START_TEST(no_err_on_shutdown)
 {
    efl_ref(widget);
@@ -204,4 +211,5 @@ efl_ui_widget_behavior_test(TCase *tc)
    tcase_add_test(tc, no_leaking_canvas_object);
    tcase_add_test(tc, no_err_on_shutdown);
    tcase_add_test(tc, correct_visibility_setting);
+   tcase_add_test(tc, no_err_on_creation);
 }