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 44b42d8ee944e58a3fd144df67b3d7e4f00fdc0d
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Nov 18 22:53:42 2026 -0600

    elementary: a layout's rebuilt part content reaches its factory alive
    
    When a factory-bound part's content was rebuilt, the old content was
    released to the factory while still in the part, and setting the new
    content then deleted it: a caching factory kept a dead object. It is
    now taken out of the part first, as the other two release paths do.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_layout.c        |  5 ++++-
 src/tests/elementary/efl_ui_test_layout.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/lib/elementary/efl_ui_layout.c b/src/lib/elementary/efl_ui_layout.c
index 68ceb1046c..c9299b9bd8 100644
--- a/src/lib/elementary/efl_ui_layout.c
+++ b/src/lib/elementary/efl_ui_layout.c
@@ -2516,8 +2516,11 @@ _content_created(Eo *obj, void *data, const Eina_Value value)
 
    EINA_VALUE_ARRAY_FOREACH(&value, len, i, content)
      {
-        // Recycle old content
+        // Recycle old content, out of the part first: setting the new content
+        // deletes whatever the part still holds, and the factory keeps what it
+        // is given back.
         old_content[0] = efl_content_get(efl_part(obj, request->key));
+        efl_content_unset(efl_part(obj, request->key));
         if (old_content[0]) efl_ui_factory_release(request->factory, EINA_C_ARRAY_ITERATOR_NEW(old_content));
 
         // Set new content
diff --git a/src/tests/elementary/efl_ui_test_layout.c b/src/tests/elementary/efl_ui_test_layout.c
index e930227481..bb66998f4b 100644
--- a/src/tests/elementary/efl_ui_test_layout.c
+++ b/src/tests/elementary/efl_ui_test_layout.c
@@ -625,6 +625,36 @@ EFL_START_TEST(efl_ui_layout_test_factory_bind_same_factory)
 }
 EFL_END_TEST
 
+/* What a part had when its content is made again goes back to the factory
+ * out of the part: setting the new content deletes whatever the part still
+ * holds, and a caching factory would keep that to hand out. */
+EFL_START_TEST(efl_ui_layout_test_rebuilt_content_is_alive_in_the_cache)
+{
+   Eo *win = win_add(NULL, "layout", EFL_UI_WIN_TYPE_BASIC);
+   Eo *model = efl_add(EFL_GENERIC_MODEL_CLASS, win);
+   Eo *factory, *item, *content = NULL;
+   int i, j;
+
+   factory = efl_add(EFL_UI_CACHING_FACTORY_CLASS, win,
+                     efl_ui_widget_factory_item_class_set(efl_added, EFL_UI_BUTTON_CLASS));
+   item = efl_add(EFL_UI_LIST_DEFAULT_ITEM_CLASS, win,
+                  efl_ui_view_model_set(efl_added, model));
+   efl_ui_factory_bind(item, "icon", factory);
+
+   /* The model saying its property changed makes the content again. */
+   for (i = 0; i < 4; i++)
+     {
+        Eina_Value v = eina_value_int_init(i);
+
+        eina_future_cancel(efl_model_property_set(model, "icon", &v));
+        for (j = 0; j < 100; j++) ecore_main_loop_iterate();
+        content = efl_content_get(efl_part(item, "icon"));
+        ck_assert_ptr_ne(content, NULL);
+        ck_assert(!efl_invalidated_get(content));
+     }
+}
+EFL_END_TEST
+
 /* The table part of a layout answers for the children packed in it. */
 EFL_START_TEST(efl_ui_layout_test_table_part_getters)
 {
@@ -1070,6 +1100,7 @@ void efl_ui_test_layout(TCase *tc)
    tcase_add_test(tc, efl_ui_layout_test_versioning);
    tcase_add_test(tc, efl_ui_layout_test_freeze);
    tcase_add_test(tc, efl_ui_layout_test_factory_bind_same_factory);
+   tcase_add_test(tc, efl_ui_layout_test_rebuilt_content_is_alive_in_the_cache);
    tcase_add_test(tc, efl_ui_layout_test_item_content_at_construction);
    tcase_add_test(tc, efl_ui_layout_test_navigation_bar_side_content);
    tcase_add_test(tc, efl_ui_layout_test_property_bind_unknown_key);

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

Reply via email to