efl_ui_win: reuse bg which was created for version check 51/236051/1
authorWooHyun Jung <wh0705.jung@samsung.com>
Fri, 12 Jun 2020 07:57:45 +0000 (16:57 +0900)
committerWooHyun Jung <wh0705.jung@samsung.com>
Fri, 12 Jun 2020 08:17:16 +0000 (17:17 +0900)
Summary: This is just for not creating bg object twice.

Reviewers: bu5hm4n, zmike, YOhoho

Reviewed By: YOhoho

Subscribers: YOhoho, cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D11936

Change-Id: I548a3f12a728d90212d47c110b2d1904b3d472b7

src/lib/elementary/efl_ui_win.c

index a1e88ad..ac2b524 100644 (file)
@@ -8595,29 +8595,28 @@ _elm_win_bg_set(Efl_Ui_Win_Data *sd, Eo *bg)
 
 /* Legacy theme compatibility */
 static Eina_Bool
-_elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd)
+_elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd, Eo **bg)
 {
    if (EINA_UNLIKELY(!sd->legacy.bg_must_swallow_init))
      {
         /* Overkill: check which theme version the standard elm_bg uses */
         Elm_Widget_Smart_Data *wd;
         const char *version;
-        Eo *bg;
         int v;
 
         sd->legacy.bg_must_swallow = 1;
         sd->legacy.bg_must_swallow_init = 1;
 
         if (sd->legacy.ctor)
-          bg = elm_bg_add(sd->obj);
+          *bg = elm_bg_add(sd->obj);
         else
           {
              // Note: This code path is probably not necessary (custom legacy
              // theme but efl_add'ed window -- all efl_add'ed widgets would
              // use default theme)
-             bg = efl_add(EFL_UI_BG_CLASS, sd->obj);
+             *bg = efl_add(EFL_UI_BG_CLASS, sd->obj);
           }
-        wd = efl_data_scope_get(bg, EFL_UI_WIDGET_CLASS);
+        wd = efl_data_scope_get(*bg, EFL_UI_WIDGET_CLASS);
         if (wd)
           {
              version = edje_object_data_get(wd->resize_obj, "version");
@@ -8625,7 +8624,6 @@ _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd)
              if (v >= FRAME_OBJ_THEME_MIN_VERSION)
                sd->legacy.bg_must_swallow = 0;
           }
-        evas_object_del(bg);
      }
 
    return sd->legacy.bg_must_swallow;
@@ -8638,29 +8636,33 @@ _elm_win_standard_init(Eo *obj)
 
    /* Support for elm_util_win_standard_add() and Efl.Ui.Win.Standard */
    Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS);
+   Eo *bg = NULL;
 
    ELM_SAFE_DEL(sd->bg);
 
    sd->csd.need_bg_standard = 1;
-   if (!_elm_win_bg_must_swallow(sd))
+   if (!_elm_win_bg_must_swallow(sd, &bg))
      {
         sd->csd.need_bg_solid = EINA_TRUE;
+        evas_object_del(bg);
      }
    else
      {
-        Eo *bg;
-
         /* Legacy theme compatibility */
         DBG("Detected legacy theme used for elm_bg. Swallowing object.");
         sd->csd.need_bg_solid = EINA_FALSE;
-        if (sd->legacy.ctor)
-          bg = elm_bg_add(obj);
-        else
+
+        if (!bg)
           {
-             // Note: This code path is probably not necessary (custom legacy
-             // theme but efl_add'ed window -- all efl_add'ed widgets would
-             // use default theme)
-             bg = efl_add(EFL_UI_BG_CLASS, obj);
+             if (sd->legacy.ctor)
+               bg = elm_bg_add(obj);
+             else
+               {
+                  // Note: This code path is probably not necessary (custom legacy
+                  // theme but efl_add'ed window -- all efl_add'ed widgets would
+                  // use default theme)
+                  bg = efl_add(EFL_UI_BG_CLASS, obj);
+               }
           }
         _elm_win_bg_set(sd, bg);
      }