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 417edc439c0f818eaf6bc1ea77fb1ad162c08c3c
Author: Cedric BAIL <[email protected]>
AuthorDate: Thu Nov 12 18:03:34 2026 -0600

    elementary: scroll connector unbind removes all that bind added
    
    efl_ui_scroll_connector_unbind freed the context but left the
    "efl,action,scroll" signal callback and the four scrollbar event
    callbacks (bar size/pos changed, show, hide) connected with it. The
    next scrollbar event after an unbind read freed memory. Efl.Ui.Scroller
    only got away with it by unbinding in its destructor, after which no
    event fires; Efl.Ui.Panel rebinds when its scrollability changes.
    
    Remove every callback bind connected, and the key data pointing at the
    context, before freeing it.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/elementary/efl_ui_scroll_util.c     | 14 ++++++++++++++
 src/tests/elementary/efl_ui_test_scroller.c | 25 +++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/src/lib/elementary/efl_ui_scroll_util.c b/src/lib/elementary/efl_ui_scroll_util.c
index 47d50165cd..513253c4cc 100644
--- a/src/lib/elementary/efl_ui_scroll_util.c
+++ b/src/lib/elementary/efl_ui_scroll_util.c
@@ -427,5 +427,19 @@ efl_ui_scroll_connector_unbind(Eo *obj)
                                   ctx, _scroll_connector_hbar_press_cb, NULL);
    efl_layout_signal_callback_del(obj, "efl,hbar,unpress", "efl",
                                   ctx, _scroll_connector_hbar_unpress_cb, NULL);
+   efl_layout_signal_callback_del(obj, "efl,action,scroll", "efl",
+                                  ctx, _scroll, NULL);
+
+   /* Everything bind connected hands ctx to its callback: leave one behind
+    * and the next scrollbar event reads the context freed below. */
+   efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED,
+                          _scroll_connector_bar_size_changed_cb, ctx);
+   efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_POS_CHANGED,
+                          _scroll_connector_bar_pos_changed_cb, ctx);
+   efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_SHOW,
+                          _scroll_connector_bar_show_cb, ctx);
+   efl_event_callback_del(obj, EFL_UI_SCROLLBAR_EVENT_BAR_HIDE,
+                          _scroll_connector_bar_hide_cb, ctx);
+   efl_key_data_set(obj, "__context", NULL);
    free(ctx);
 }
diff --git a/src/tests/elementary/efl_ui_test_scroller.c b/src/tests/elementary/efl_ui_test_scroller.c
index 14d03c6525..92a5665e8b 100644
--- a/src/tests/elementary/efl_ui_test_scroller.c
+++ b/src/tests/elementary/efl_ui_test_scroller.c
@@ -194,8 +194,33 @@ EFL_START_TEST(efl_ui_test_scroller_scrollbar)
 }
 EFL_END_TEST
 
+/* A panel binds the scrollbar events of its scroll manager to its theme when it
+   becomes scrollable, and unbinds them when it stops being: an event raised
+   after that must not reach what the unbind freed. */
+EFL_START_TEST(efl_ui_test_scroller_connector_unbind)
+{
+   Eo *win = win_add(NULL, "win", EFL_UI_WIN_TYPE_BASIC);
+   Eo *panel = efl_add(EFL_UI_PANEL_CLASS, win);
+   unsigned int unbound;
+   Eina_Size2D size = EINA_SIZE2D(1, 1);
+
+   efl_ui_panel_scrollable_set(panel, EINA_FALSE);
+   unbound = efl_event_callback_count(panel, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED);
+
+   efl_ui_panel_scrollable_set(panel, EINA_TRUE);
+   ck_assert_uint_gt(efl_event_callback_count(panel, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED),
+                     unbound);
+
+   efl_ui_panel_scrollable_set(panel, EINA_FALSE);
+   ck_assert_uint_eq(efl_event_callback_count(panel, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED),
+                     unbound);
+   efl_event_callback_call(panel, EFL_UI_SCROLLBAR_EVENT_BAR_SIZE_CHANGED, &size);
+}
+EFL_END_TEST
+
 void efl_ui_test_scroller(TCase *tc)
 {
    tcase_add_test(tc, efl_ui_test_scroller_events);
    tcase_add_test(tc, efl_ui_test_scroller_scrollbar);
+   tcase_add_test(tc, efl_ui_test_scroller_connector_unbind);
 }

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

Reply via email to