Use thread safety function. 71/124271/1
authorWoochan Lee <wc0917.lee@samsung.com>
Tue, 11 Apr 2017 04:41:45 +0000 (13:41 +0900)
committerWoochan Lee <wc0917.lee@samsung.com>
Tue, 11 Apr 2017 04:42:40 +0000 (13:42 +0900)
WGID: 172073

Change-Id: I63f29ce4c9fb390eb2f2573bba5544f7e0a76323

src/bin/test_calendar.c

index 35e1bf95a645a8607d2c52dee6f7bda7d354b7d1..f7ff4fef0dd6b93789490d705d803721543fc9a9 100644 (file)
@@ -29,6 +29,7 @@ set_api_state(api_data *api)
 {
    const Eina_List *items = elm_box_children_get(api->box);
    static Elm_Calendar_Mark *m = NULL;
+   struct tm t;
    if (!eina_list_count(items))
      return;
 
@@ -38,8 +39,8 @@ set_api_state(api_data *api)
            {
               Evas_Object *cal = eina_list_nth(items, 0);
               time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
-              m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY);
-              elm_calendar_selected_time_set(cal, gmtime(&the_time));
+              m = elm_calendar_mark_add(cal, "checked", gmtime_r(&the_time, &t), ELM_CALENDAR_MONTHLY);
+              elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
            }
          break;
       case STATE_MARK_WEEKLY:
@@ -47,8 +48,8 @@ set_api_state(api_data *api)
               Evas_Object *cal = eina_list_nth(items, 0);
               time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 4); /* Set date to DEC 26, 2010 */
               elm_calendar_mark_del(m);
-              m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
-              elm_calendar_selected_time_set(cal, gmtime(&the_time));
+              m = elm_calendar_mark_add(cal, "checked", gmtime_r(&the_time, &t), ELM_CALENDAR_WEEKLY);
+              elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
            }
          break;
       case STATE_SUNDAY_HIGHLIGHT:
@@ -56,8 +57,8 @@ set_api_state(api_data *api)
               Evas_Object *cal = eina_list_nth(items, 0);
               time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 3); /* Set date to DEC 25, 2010 */
               /* elm_calendar_mark_del(m); */
-              m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
-              elm_calendar_selected_time_set(cal, gmtime(&the_time));
+              m = elm_calendar_mark_add(cal, "holiday", gmtime_r(&the_time, &t), ELM_CALENDAR_WEEKLY);
+              elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
            }
          break;
       case STATE_SELECT_DATE_DISABLED_WITH_MARKS:
@@ -65,7 +66,7 @@ set_api_state(api_data *api)
               Evas_Object *cal = eina_list_nth(items, 0);
               time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 10); /* Set date to JAN 01, 2011 */
               elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
-              elm_calendar_selected_time_set(cal, gmtime(&the_time));
+              elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
            }
          break;
       case STATE_SELECT_DATE_DISABLED_NO_MARKS:
@@ -74,7 +75,7 @@ set_api_state(api_data *api)
               time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 40); /* Set date to FEB 01, 2011 */
               elm_calendar_marks_clear(cal);
               elm_calendar_select_mode_set(cal, ELM_CALENDAR_SELECT_MODE_NONE);
-              elm_calendar_selected_time_set(cal, gmtime(&the_time));
+              elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
            }
          break;
       case API_STATE_LAST:
@@ -141,7 +142,8 @@ test_calendar(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
    elm_box_pack_end(bx, cal);
 
    time_t the_time = (SEC_PER_YEAR * 41) + (SEC_PER_DAY * 9); /* Set date to DEC 31, 2010 */
-   elm_calendar_selected_time_set(cal, gmtime(&the_time));
+   struct tm t;
+   elm_calendar_selected_time_set(cal, gmtime_r(&the_time, &t));
 
    evas_object_show(cal);
 
@@ -221,7 +223,7 @@ _calendar_create(Evas_Object *parent)
 {
    Evas_Object *cal;
    Elm_Calendar_Mark *mark;
-   struct tm selected_time;
+   struct tm selected_time, t;
    time_t current_time;
    const char *weekdays[] =
    {
@@ -236,9 +238,9 @@ _calendar_create(Evas_Object *parent)
    elm_calendar_format_function_set(cal, _format_month_year);
 
    time_t the_time = (SEC_PER_YEAR * 40) + (SEC_PER_DAY * 24); /* Set min date to JAN 15, 2010 */
-   elm_calendar_date_min_set(cal, gmtime(&the_time));
+   elm_calendar_date_min_set(cal, gmtime_r(&the_time, &t));
    the_time = (SEC_PER_YEAR * 42) + (SEC_PER_DAY * 3); /* Set max date to DEC 25, 2011 */
-   elm_calendar_date_max_set(cal, gmtime(&the_time));
+   elm_calendar_date_max_set(cal, gmtime_r(&the_time, &t));
 
    current_time = time(NULL) + 4 * SEC_PER_DAY;
    localtime_r(&current_time, &selected_time);