summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2018-11-10 14:31:27 +0100
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2018-11-10 14:31:27 +0100
commitb80dfe49bca4c0f89c78cc0ca92fc58567e1d0ae (patch)
tree4946d2005e43e763646b9825fa2498e64f51eb60
parenta0df88240d056c99b47350efb402fe91110597b3 (diff)
-rw-r--r--src/lib/eo/eo_event_emitter.c13
-rw-r--r--src/tests/eo/suite/eo_test_event.c11
2 files changed, 19 insertions, 5 deletions
diff --git a/src/lib/eo/eo_event_emitter.c b/src/lib/eo/eo_event_emitter.c
index 89e4cd2529..3d60f6a69f 100644
--- a/src/lib/eo/eo_event_emitter.c
+++ b/src/lib/eo/eo_event_emitter.c
@@ -31,6 +31,7 @@ static int
31_callback_node_cb(const void *a, const void *b) 31_callback_node_cb(const void *a, const void *b)
32{ 32{
33 const Callback_Node *ca = a, *cb = b; 33 const Callback_Node *ca = a, *cb = b;
34 printf("%d vs. %d\n", ca->priority, cb->priority);
34 35
35 if (ca->priority < cb->priority) return 1; 36 if (ca->priority < cb->priority) return 1;
36 else if (ca->priority == cb->priority) return 0; 37 else if (ca->priority == cb->priority) return 0;
@@ -226,6 +227,10 @@ eo_event_emitter_register(Eo_Event_Emitter *emitter, Efl_Event_Cb cb, const Efl_
226 } 227 }
227 228
228 cb_index = eina_inarray_search_sorted(ev_node->callback.chain, &new_callback_node, _callback_node_cb); 229 cb_index = eina_inarray_search_sorted(ev_node->callback.chain, &new_callback_node, _callback_node_cb);
230
231 if (cb_index == -1)
232 eina_inarray_insert_sorted(ev_node->callback.chain, &new_callback_node, _callback_node_cb);
233 else {
229 //we are searching now for the first element that has a different element in priority, to the higher side 234 //we are searching now for the first element that has a different element in priority, to the higher side
230 while(cb_index + 1 < eina_inarray_count(ev_node->callback.chain)) 235 while(cb_index + 1 < eina_inarray_count(ev_node->callback.chain))
231 { 236 {
@@ -234,7 +239,15 @@ eo_event_emitter_register(Eo_Event_Emitter *emitter, Efl_Event_Cb cb, const Efl_
234 break; 239 break;
235 cb_index ++; 240 cb_index ++;
236 } 241 }
242 printf("%d\n", cb_index);
237 eina_inarray_insert_at(ev_node->callback.chain, cb_index + 1, &new_callback_node); 243 eina_inarray_insert_at(ev_node->callback.chain, cb_index + 1, &new_callback_node);
244 }
245
246 for (int i = 0; i < eina_inarray_count(ev_node->callback.chain); ++i)
247 {
248 Callback_Node *node = eina_inarray_nth(ev_node->callback.chain, i);
249 printf("%d\n", node->priority);
250 }
238 251
239 for (Eo_Event_Emitter_Frame *frame = emitter->most_recent ; frame; frame = frame->prev) 252 for (Eo_Event_Emitter_Frame *frame = emitter->most_recent ; frame; frame = frame->prev)
240 { 253 {
diff --git a/src/tests/eo/suite/eo_test_event.c b/src/tests/eo/suite/eo_test_event.c
index bf4b7828ba..6872c96240 100644
--- a/src/tests/eo/suite/eo_test_event.c
+++ b/src/tests/eo/suite/eo_test_event.c
@@ -262,15 +262,15 @@ EFL_START_TEST(eo_event_basic_order)
262 int flag[] = { 0,0,0,0,0,0,0,0,0 }; 262 int flag[] = { 0,0,0,0,0,0,0,0,0 };
263 263
264 eo_event_emitter_init(&emitter); 264 eo_event_emitter_init(&emitter);
265 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[8]);
266 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[7]);
267 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[6]);
265 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[2]); 268 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[2]);
266 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[1]); 269 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[1]);
267 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[0]); 270 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[0]);
268 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, 0, &flag[5]); 271 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, 0, &flag[5]);
269 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, 0, &flag[4]); 272 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, 0, &flag[4]);
270 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, 0, &flag[3]); 273 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, 0, &flag[3]);
271 eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[8]);
272 eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[7]);
273 eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[6]);
274 274
275 counter = 0; 275 counter = 0;
276 276
@@ -278,6 +278,7 @@ EFL_START_TEST(eo_event_basic_order)
278 278
279 for (int i = 0; i < 9; ++i) 279 for (int i = 0; i < 9; ++i)
280 { 280 {
281 printf("%d: %d\n", flag[i], i);
281 ck_assert_int_eq(flag[i], i); 282 ck_assert_int_eq(flag[i], i);
282 } 283 }
283} 284}
@@ -285,10 +286,10 @@ EFL_END_TEST
285 286
286void eo_test_event(TCase *tc) 287void eo_test_event(TCase *tc)
287{ 288{
288 tcase_add_test(tc, eo_event); 289 /*tcase_add_test(tc, eo_event);
289 tcase_add_test(tc, eo_event_call_in_call); 290 tcase_add_test(tc, eo_event_call_in_call);
290 tcase_add_test(tc, eo_event_generation_bug); 291 tcase_add_test(tc, eo_event_generation_bug);
291 tcase_add_test(tc, eo_event_basic); 292 tcase_add_test(tc, eo_event_basic);*/
292 tcase_add_test(tc, eo_event_basic_order); 293 tcase_add_test(tc, eo_event_basic_order);
293} 294}
294 295