This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository efl.

View the commit online.

commit 990d92566a68742cb6682b3cbf72944c5c6edfe9
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 8 01:21:31 2026 -0600

    elementary: a window replaces its content cleanly
    
    Setting a new content on a window left the previous one in the box with
    its weak reference on the slot, so deleting it afterwards cleared the
    slot of the content that had replaced it. Remove the previous content
    first, as Efl.Content.content says, and let a null content empty the
    slot.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_win.c        | 15 ++++++++++++++-
 src/tests/elementary/efl_ui_test_win.c | 23 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 47dfde2dbe..44de8f33bc 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -7744,7 +7744,20 @@ _efl_ui_win_content_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *part, Eo *cont
    if (eina_streq(part, "content"))
      {
         if (sd->content == content) return EINA_TRUE;
-        if (content && !elm_widget_sub_object_add(obj, content))
+        // The previous content goes first (@Efl.Content.content says so): left
+        // in the box, with its weak reference on, it would clear the slot of the
+        // content that replaced it when it is deleted.
+        if (sd->content)
+          {
+             Eo *prev = sd->content;
+
+             efl_wref_del(prev, &sd->content);
+             sd->content = NULL;
+             evas_object_box_remove(sd->legacy.box, prev);
+             elm_widget_sub_object_del(obj, prev);
+          }
+        if (!content) return EINA_TRUE;
+        if (!elm_widget_sub_object_add(obj, content))
           goto err;
         /* FIXME: Switch to swallow inside the frame
         if (!edje_object_part_swallow(sd->frame_obj, "elm.swallow.client", content))
diff --git a/src/tests/elementary/efl_ui_test_win.c b/src/tests/elementary/efl_ui_test_win.c
index 690dac6589..757df836c6 100644
--- a/src/tests/elementary/efl_ui_test_win.c
+++ b/src/tests/elementary/efl_ui_test_win.c
@@ -509,6 +509,28 @@ EFL_START_TEST(efl_ui_win_test_type)
 }
 EFL_END_TEST
 
+EFL_START_TEST(efl_ui_win_test_content_replaced)
+{
+   Efl_Ui_Win *win;
+   Eo *a, *b;
+
+   win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+   a = efl_add(EFL_UI_BUTTON_CLASS, win);
+   b = efl_add(EFL_UI_BUTTON_CLASS, win);
+
+   efl_content_set(win, a);
+   ck_assert_ptr_eq(efl_content_get(win), a);
+   efl_content_set(win, b);
+   ck_assert_ptr_eq(efl_content_get(win), b);
+
+   efl_del(a);
+   ck_assert_ptr_eq(efl_content_get(win), b);
+
+   efl_content_set(win, NULL);
+   ck_assert_ptr_eq(efl_content_get(win), NULL);
+}
+EFL_END_TEST
+
 void
 efl_ui_test_win(TCase *tc)
 {
@@ -527,4 +549,5 @@ efl_ui_test_win(TCase *tc)
    tcase_add_test(tc, efl_ui_win_test_device_added_removed);
    tcase_add_test(tc, efl_ui_win_test_rotation_normalized);
    tcase_add_test(tc, efl_ui_win_test_type);
+   tcase_add_test(tc, efl_ui_win_test_content_replaced);
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to