popup: fix unintentional object deletion when change scrollable
authorJinYong Park <j4939.park@samsung.com>
Mon, 5 Jun 2017 18:08:45 +0000 (11:08 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Mon, 5 Jun 2017 19:07:56 +0000 (12:07 -0700)
Summary:
If popup scrollable change from FALSE to TRUE after content or text is added,
content_area is deleted, so it cause null pointer problem.
main_layout has content_area in its CONTENT_PART, but in scrollable_set API,
tbl set into main_layout's CONTENT_PART, so content_area is deleted.

On the contrary, if scrollable change to FALSE,
content object in content_area is deleted, because tbl set into content_area's CONTENT_PART.

So if some object set into other object,
unset previous object and set it into properly part after that.

A case using item_append should be fixed by other patch.

@fix

Test Plan: Change scrollable repeatedly after adding content or text to popup.

Reviewers: jpeg, singh.amitesh, conr2d, cedric, raster

Reviewed By: cedric

Subscribers: herb

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

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/lib/elementary/elc_popup.c

index afeb003..f519d76 100644 (file)
@@ -673,6 +673,7 @@ _create_scroller(Evas_Object *obj)
                                   _on_table_del, obj);
    if (!sd->scroll)
      {
+        if (sd->content || sd->text_content_obj) efl_content_unset(efl_part(sd->content_area, CONTENT_PART));
         efl_content_set(efl_part(sd->content_area, CONTENT_PART), sd->tbl);
         efl_content_set(efl_part(sd->main_layout, CONTENT_PART), sd->content_area);
      }
@@ -1840,7 +1841,7 @@ _elm_popup_scrollable_set(Eo *obj, Elm_Popup_Data *pd, Eina_Bool scroll)
      _create_scroller(obj);
    else
      {
-        elm_layout_content_unset(pd->scr, "elm.swallow.content");
+        elm_object_content_unset(pd->scr);
         ELM_SAFE_FREE(pd->tbl, evas_object_del);
         _create_scroller(obj);
      }
@@ -1849,11 +1850,18 @@ _elm_popup_scrollable_set(Eo *obj, Elm_Popup_Data *pd, Eina_Bool scroll)
      {
         efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->tbl);
         efl_content_set(efl_part(pd->main_layout, CONTENT_PART), pd->content_area);
+        if (pd->content) efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->content);
+        else if (pd->text_content_obj) efl_content_set(efl_part(pd->content_area, CONTENT_PART), pd->text_content_obj);
         if (pd->theme_scroll)
           elm_layout_signal_emit(pd->content_area, "elm,scroll,disable", "elm");
      }
    else
      {
+        if (pd->content || pd->text_content_obj)
+          {
+             efl_content_unset(efl_part(pd->main_layout, CONTENT_PART));
+             elm_object_content_set(pd->scr, pd->content_area);
+          }
         efl_content_set(efl_part(pd->main_layout, CONTENT_PART), pd->tbl);
         if (pd->theme_scroll)
           elm_layout_signal_emit(pd->content_area, "elm,scroll,enable", "elm");