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 3dc70433a74f24ae844cd01ed9ebfb141fb27f06
Author: Cedric BAIL <[email protected]>
AuthorDate: Sun Nov 15 12:26:02 2026 -0600

    ecore: a copier whose source or destination is set late starts copying
    
    Efl.Io.Copier starts its first copy at finalize, when whatever was set
    at construction already has data. Setting the source or the destination
    afterwards wired up the callbacks and then waited for a
    can_read,changed that had already happened, so the copier sat idle
    forever. A binding that finalizes an object before the caller can set
    anything cannot use the class at all because of that.
    
    A set on a finalized, running copier now does what finalize does.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 src/lib/ecore/efl_io_copier.c     | 19 +++++++++++++
 src/tests/ecore/efl_app_suite.c   |  1 +
 src/tests/ecore/efl_app_suite.h   |  1 +
 src/tests/ecore/efl_app_test_io.c | 59 +++++++++++++++++++++++++++++++++++++++
 src/tests/ecore/meson.build       |  1 +
 5 files changed, 81 insertions(+)

diff --git a/src/lib/ecore/efl_io_copier.c b/src/lib/ecore/efl_io_copier.c
index dbedfcf959..ac000538bf 100644
--- a/src/lib/ecore/efl_io_copier.c
+++ b/src/lib/ecore/efl_io_copier.c
@@ -405,6 +405,21 @@ _efl_io_copier_source_get(const Eo *o EINA_UNUSED, Efl_Io_Copier_Data *pd)
    return pd->source;
 }
 
+/* A source or destination set after finalize starts the copy finalize would
+ * have started.
+ */
+static void
+_efl_io_copier_restart_if_running(Eo *o, Efl_Io_Copier_Data *pd)
+{
+   if (!efl_finalized_get(o) || efl_invalidated_get(o)) return;
+   if (pd->closed) return;
+   if (!efl_loop_get(o)) return;
+
+   if ((pd->source && efl_io_reader_can_read_get(pd->source)) ||
+       (pd->destination && efl_io_writer_can_write_get(pd->destination)))
+     _efl_io_copier_job_schedule(o, pd);
+}
+
 EOLIAN static void
 _efl_io_copier_source_set(Eo *o, Efl_Io_Copier_Data *pd, Efl_Io_Reader *source)
 {
@@ -449,6 +464,8 @@ _efl_io_copier_source_set(Eo *o, Efl_Io_Copier_Data *pd, Efl_Io_Reader *source)
                                      _efl_io_copier_source_closed, o);
           }
      }
+
+   _efl_io_copier_restart_if_running(o, pd);
 }
 
 static void
@@ -533,6 +550,8 @@ _efl_io_copier_destination_set(Eo *o, Efl_Io_Copier_Data *pd, Efl_Io_Writer *des
              efl_io_sizer_resize(pd->destination, pd->progress.total);
           }
      }
+
+   _efl_io_copier_restart_if_running(o, pd);
 }
 
 EOLIAN static void
diff --git a/src/tests/ecore/efl_app_suite.c b/src/tests/ecore/efl_app_suite.c
index 957cb3099e..c5dee5df00 100644
--- a/src/tests/ecore/efl_app_suite.c
+++ b/src/tests/ecore/efl_app_suite.c
@@ -54,6 +54,7 @@ static const Efl_Test_Case etc[] = {
   { "Promise", efl_app_test_promise_safety },
   { "Env", efl_test_efl_env },
   { "CML", efl_test_efl_cml },
+  { "Io", efl_app_test_efl_io },
   { NULL, NULL }
 };
 
diff --git a/src/tests/ecore/efl_app_suite.h b/src/tests/ecore/efl_app_suite.h
index 874d2bb503..22c9c1d1fe 100644
--- a/src/tests/ecore/efl_app_suite.h
+++ b/src/tests/ecore/efl_app_suite.h
@@ -7,6 +7,7 @@ void efl_app_test_efl_app(TCase *tc);
 void efl_app_test_efl_loop(TCase *tc);
 void efl_app_test_efl_loop_fd(TCase *tc);
 void efl_app_test_efl_loop_timer(TCase *tc);
+void efl_app_test_efl_io(TCase *tc);
 void efl_app_test_promise(TCase *tc);
 void efl_app_test_promise_2(TCase *tc);
 void efl_app_test_promise_3(TCase *tc);
diff --git a/src/tests/ecore/efl_app_test_io.c b/src/tests/ecore/efl_app_test_io.c
new file mode 100644
index 0000000000..86bad8eb4c
--- /dev/null
+++ b/src/tests/ecore/efl_app_test_io.c
@@ -0,0 +1,59 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define EFL_BETA_API_SUPPORT
+#define EFL_NOLEGACY_API_SUPPORT
+#include <Efl_Core.h>
+#include "efl_app_suite.h"
+#include "../efl_check.h"
+
+static const char payload[] = "the quick brown fox jumps over the lazy dog";
+
+static void
+_copier_done(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Eina_Bool *done = data;
+
+   *done = EINA_TRUE;
+   efl_loop_quit(efl_main_loop_get(), eina_value_int_init(0));
+}
+
+/* A source set after construction still starts the copy of what it holds. */
+EFL_START_TEST(efl_io_test_copier_source_set_after_construction)
+{
+   Eo *source, *copier;
+   Eina_Slice to_write;
+   Eina_Bool done = EINA_FALSE;
+   Eina_Binbuf *collected;
+
+   source = efl_add(EFL_IO_BUFFER_CLASS, efl_main_loop_get());
+   to_write.mem = payload;
+   to_write.len = sizeof(payload) - 1;
+   efl_io_writer_write(source, &to_write, NULL);
+
+   copier = efl_add(EFL_IO_COPIER_CLASS, efl_main_loop_get(),
+                    efl_event_callback_add(efl_added, EFL_IO_COPIER_EVENT_DONE,
+                                           _copier_done, &done));
+   fail_if(!copier);
+
+   efl_io_copier_source_set(copier, source);
+
+   efl_loop_begin(efl_main_loop_get());
+   ck_assert(done);
+
+   collected = efl_io_copier_binbuf_steal(copier);
+   fail_if(!collected);
+   ck_assert_int_eq(eina_binbuf_length_get(collected), sizeof(payload) - 1);
+   eina_binbuf_free(collected);
+
+   efl_del(copier);
+   efl_del(source);
+}
+EFL_END_TEST
+
+void
+efl_app_test_efl_io(TCase *tc)
+{
+   tcase_add_test(tc, efl_io_test_copier_source_set_after_construction);
+}
diff --git a/src/tests/ecore/meson.build b/src/tests/ecore/meson.build
index 84eaef9afe..8dcf72f6f3 100644
--- a/src/tests/ecore/meson.build
+++ b/src/tests/ecore/meson.build
@@ -85,6 +85,7 @@ efl_app_suite_src = [
   'efl_app_test_promise.c',
   'efl_app_test_env.c',
   'efl_app_test_cml.c',
+  'efl_app_test_io.c',
 ]
 
 priv_eo_files = [

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

Reply via email to