summaryrefslogtreecommitdiff
path: root/src/tests/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-02-23 08:57:19 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-02-23 08:57:48 -0500
commit301b05502cff4125633da25e46d5cf0dccd1565a (patch)
tree9b4cbd3387bd193872cbf3497d8fb28c41407218 /src/tests/eio
parent790fc1b8c5ce819dc7e17063baad52968b0c6706 (diff)
eio: enforce proper lifecycle for all Efl.Io_Model and fix discovered lifecycle bugs.
Summary: This make sure that the object returned by children_slice_get are properly destroyed when the refcount drop to only the parent holding a reference on it. This make it clear that the user of the api can rely on efl_ref/efl_unref to actually manage its use of the returned object. Additionnaly we are cleaning up the created object that we are using to build our own request inside the Efl.Io.Model and avoid internal leak. Depends on D7864 Reviewers: felipealmeida, segfaultxavi, SanghyeonLee, zmike, bu5hm4n Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T7528 Differential Revision: https://phab.enlightenment.org/D7865
Diffstat (limited to 'src/tests/eio')
-rw-r--r--src/tests/eio/efl_io_model_test_monitor_add.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/tests/eio/efl_io_model_test_monitor_add.c b/src/tests/eio/efl_io_model_test_monitor_add.c
index 7fee539015..35e217aa63 100644
--- a/src/tests/eio/efl_io_model_test_monitor_add.c
+++ b/src/tests/eio/efl_io_model_test_monitor_add.c
@@ -16,6 +16,52 @@ Eina_Tmpstr* temp_filename = NULL;
16const char* tmpdir = NULL; 16const char* tmpdir = NULL;
17Eina_Bool children_deleted = EINA_FALSE; 17Eina_Bool children_deleted = EINA_FALSE;
18 18
19// This will ensure that the child have the time to be automatically destroyed
20static Eina_Value
21_delayed_quit(Eo *o EINA_UNUSED, void *data EINA_UNUSED, const Eina_Value v)
22{
23 ecore_main_loop_quit();
24
25 return v;
26}
27
28static Eina_Value
29_children_got(Eo *o, void *data EINA_UNUSED, const Eina_Value v)
30{
31 Eo *child = NULL;
32 unsigned int i, len;
33 Eina_Value r = (Eina_Value) v;
34
35 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
36 {
37 Eina_Value *path;
38 char *str;
39
40 path = efl_model_property_get(child, "path");
41 fail_if(path == NULL);
42 str = eina_value_to_string(path);
43 fail_if(str == NULL);
44
45 if (temp_filename && strcmp(str, temp_filename) == 0)
46 r = eina_future_as_value(efl_future_then(efl_loop_get(o),
47 efl_loop_job(efl_loop_get(o)),
48 .success = _delayed_quit));
49
50
51 free(str);
52 eina_value_free(path);
53 }
54
55 return r;
56}
57
58static Eina_Value
59_children_failed(Eo *o EINA_UNUSED, void *data EINA_UNUSED, const Eina_Error err)
60{
61 ck_abort_msg( "Failed to get the child with '%s'.\n", eina_error_msg_get(err));
62 return eina_value_error_init(err);
63}
64
19static void 65static void
20_children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event) 66_children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event)
21{ 67{
@@ -23,6 +69,20 @@ _children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event)
23 Eina_Value *path; 69 Eina_Value *path;
24 char *str; 70 char *str;
25 71
72 if (!evt->child)
73 {
74 Eina_Future *f;
75
76 // Last time we can fetch the object
77 f = efl_future_then(event->object,
78 efl_model_children_slice_get(event->object, evt->index, 1),
79 .success = _children_got,
80 .error = _children_failed,
81 .success_type = EINA_VALUE_TYPE_ARRAY);
82 fail_if(f == NULL);
83 return;
84 }
85
26 fail_if(evt->child == NULL); 86 fail_if(evt->child == NULL);
27 path = efl_model_property_get(evt->child, "path"); 87 path = efl_model_property_get(evt->child, "path");
28 fail_if(path == NULL); 88 fail_if(path == NULL);
@@ -30,7 +90,9 @@ _children_removed_cb(void *data EINA_UNUSED, const Efl_Event* event)
30 fail_if(str == NULL); 90 fail_if(str == NULL);
31 91
32 if (temp_filename && strcmp(str, temp_filename) == 0) 92 if (temp_filename && strcmp(str, temp_filename) == 0)
33 ecore_main_loop_quit(); 93 efl_future_then(efl_loop_get(evt->child),
94 efl_loop_job(efl_loop_get(evt->child)),
95 .success = _delayed_quit);
34 96
35 free(str); 97 free(str);
36 eina_value_free(path); 98 eina_value_free(path);