elementary/naviframe - refactored title_content_set
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 16 Dec 2011 09:07:41 +0000 (09:07 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 16 Dec 2011 09:07:41 +0000 (09:07 +0000)
fault here again!

it would missed one case.

step 1. actual content set
step 2. NULL content set

Since it did not remove content_pair structure even NULL object as a new one set,
the dangling structure could be happened.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@66274 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elc_naviframe.c

index 743aeb9..0bc945e 100644 (file)
@@ -562,7 +562,26 @@ _title_content_set(Elm_Naviframe_Item *it,
    EINA_INLIST_FOREACH(it->content_list, pair)
      if (!strcmp(part, pair->part)) break;
 
-   if (!pair)
+   if (part)
+     {
+        if (pair->content && (pair->content != content))
+          {
+             if (content)
+               {
+                  evas_object_event_callback_del(pair->content,
+                                                 EVAS_CALLBACK_DEL,
+                                                 _title_content_del);
+                  evas_object_event_callback_del(pair->content,
+                                                 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
+                                                 _changed_size_hints);
+                  snprintf(buf, sizeof(buf), "elm,state,%s,hide", part);
+                  edje_object_signal_emit(VIEW(it), buf, "elm");
+               }
+             evas_object_del(pair->content);
+             if (!content) return;
+          }
+     }
+   else
      {
         if (!content) return;
         pair = ELM_NEW(Elm_Naviframe_Content_Item_Pair);
@@ -575,38 +594,20 @@ _title_content_set(Elm_Naviframe_Item *it,
         eina_stringshare_replace(&pair->part, part);
         it->content_list = eina_inlist_append(it->content_list,
                                               EINA_INLIST_GET(pair));
-     }
-   if (pair->content && (pair->content != content))
-     {
-        evas_object_event_callback_del(pair->content,
+        elm_widget_sub_object_add(WIDGET(it), content);
+        evas_object_event_callback_add(content,
                                        EVAS_CALLBACK_DEL,
-                                       _title_content_del);
-        evas_object_event_callback_del(pair->content,
+                                       _title_content_del,
+                                       pair);
+        evas_object_event_callback_add(content,
                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                       _changed_size_hints);
-        evas_object_del(pair->content);
-        snprintf(buf, sizeof(buf), "elm,state,%s,hide", part);
-        edje_object_signal_emit(VIEW(it), buf, "elm");
-     }
-   if (content)
-     {
-        if (pair->content != content)
-          {
-             elm_widget_sub_object_add(WIDGET(it), content);
-             evas_object_event_callback_add(content,
-                                            EVAS_CALLBACK_DEL,
-                                            _title_content_del,
-                                            pair);
-             evas_object_event_callback_add(content,
-                                            EVAS_CALLBACK_CHANGED_SIZE_HINTS,
-                                            _changed_size_hints,
-                                            WIDGET(it));
-             pair->content = content;
-          }
-        edje_object_part_swallow(VIEW(it), part, content);
-        snprintf(buf, sizeof(buf), "elm,state,%s,show", part);
-        edje_object_signal_emit(VIEW(it), buf, "elm");
+                                       _changed_size_hints,
+                                       WIDGET(it));
      }
+     edje_object_part_swallow(VIEW(it), part, content);
+     snprintf(buf, sizeof(buf), "elm,state,%s,show", part);
+     edje_object_signal_emit(VIEW(it), buf, "elm");
+     pair->content = content;
 
    _sizing_eval(WIDGET(it));
 }