datetime: Delay elm_layout_theme_set until memebers are initialized in _smart_add
authorRyuan Choi <ryuan.choi@gmail.com>
Thu, 16 Jan 2014 13:44:07 +0000 (22:44 +0900)
committerRyuan Choi <ryuan.choi@gmail.com>
Thu, 16 Jan 2014 13:50:40 +0000 (22:50 +0900)
There are some warnings in elm_object_disabled_set() because elm_layout_theme_set()
calls _elm_datetime_smart_disable() before creating file->item_obj.
This patch refactors _smart_add to initialize file->item_obj before calling
elm_layout_theme_set().

src/lib/elm_datetime.c

index 42d6c8076eb881d09bbf53a44ec98a8ff95ada07..008b687a60a969d091e1652409e7240a5b148856 100644 (file)
@@ -803,34 +803,40 @@ _elm_datetime_smart_add(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
    eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
    elm_widget_sub_object_parent_add(obj);
 
-   if (!elm_layout_theme_set(obj, "datetime", "base",
-                             elm_widget_style_get(obj)))
-     CRI("Failed to set layout!");
-
    // module - initialise module for datetime
    if (!dt_mod) dt_mod = _dt_mod_init();
-   if ((dt_mod) && (dt_mod->obj_hook)) priv->mod_data = dt_mod->obj_hook(obj);
-
-   // update module data
-   if (priv->mod_data)
+   if (dt_mod)
      {
-        priv->mod_data->base = obj;
-        priv->mod_data->field_limit_get = _field_limit_get;
-        priv->mod_data->field_format_get = _field_format_get;
-     }
+        if (dt_mod->obj_hook)
+          {
+             priv->mod_data = dt_mod->obj_hook(obj);
 
-   _field_list_init(obj);
-   _reload_format(obj);
+             // update module data
+             if (priv->mod_data)
+               {
+                  priv->mod_data->base = obj;
+                  priv->mod_data->field_limit_get = _field_limit_get;
+                  priv->mod_data->field_format_get = _field_format_get;
+               }
+          }
 
-   if ((dt_mod) && (dt_mod->field_create))
-     {
-        for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
+        if (dt_mod->field_create)
           {
-             field = priv->field_list + idx;
-             field->item_obj = dt_mod->field_create(priv->mod_data, idx);
+             for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)
+               {
+                  field = priv->field_list + idx;
+                  field->item_obj = dt_mod->field_create(priv->mod_data, idx);
+               }
           }
      }
 
+   if (!elm_layout_theme_set(obj, "datetime", "base",
+                             elm_widget_style_get(obj)))
+     CRI("Failed to set layout!");
+
+   _field_list_init(obj);
+   _reload_format(obj);
+
    _field_list_arrange(obj);
 
    elm_widget_can_focus_set(obj, EINA_TRUE);