aboutsummaryrefslogtreecommitdiffstats
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
parentwip-port (diff)
downloadefl-devs/bu5hm4n/eo-event-rewrite.tar.gz
-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
_callback_node_cb(const void *a, const void *b)
{
const Callback_Node *ca = a, *cb = b;
+ printf("%d vs. %d\n", ca->priority, cb->priority);
if (ca->priority < cb->priority) return 1;
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_
}
cb_index = eina_inarray_search_sorted(ev_node->callback.chain, &new_callback_node, _callback_node_cb);
+
+ if (cb_index == -1)
+ eina_inarray_insert_sorted(ev_node->callback.chain, &new_callback_node, _callback_node_cb);
+ else {
//we are searching now for the first element that has a different element in priority, to the higher side
while(cb_index + 1 < eina_inarray_count(ev_node->callback.chain))
{
@@ -234,7 +239,15 @@ eo_event_emitter_register(Eo_Event_Emitter *emitter, Efl_Event_Cb cb, const Efl_
break;
cb_index ++;
}
+ printf("%d\n", cb_index);
eina_inarray_insert_at(ev_node->callback.chain, cb_index + 1, &new_callback_node);
+ }
+
+ for (int i = 0; i < eina_inarray_count(ev_node->callback.chain); ++i)
+ {
+ Callback_Node *node = eina_inarray_nth(ev_node->callback.chain, i);
+ printf("%d\n", node->priority);
+ }
for (Eo_Event_Emitter_Frame *frame = emitter->most_recent ; frame; frame = frame->prev)
{
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)
int flag[] = { 0,0,0,0,0,0,0,0,0 };
eo_event_emitter_init(&emitter);
+ eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[8]);
+ eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[7]);
+ eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[6]);
eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[2]);
eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[1]);
eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_BEFORE, &flag[0]);
eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, 0, &flag[5]);
eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, 0, &flag[4]);
eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, 0, &flag[3]);
- eo_event_emitter_register(&emitter, _ncb1, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[8]);
- eo_event_emitter_register(&emitter, _ncb2, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[7]);
- eo_event_emitter_register(&emitter, _ncb3, EFL_EVENT_DEL, EFL_CALLBACK_PRIORITY_AFTER, &flag[6]);
counter = 0;
@@ -278,6 +278,7 @@ EFL_START_TEST(eo_event_basic_order)
for (int i = 0; i < 9; ++i)
{
+ printf("%d: %d\n", flag[i], i);
ck_assert_int_eq(flag[i], i);
}
}
@@ -285,10 +286,10 @@ EFL_END_TEST
void eo_test_event(TCase *tc)
{
- tcase_add_test(tc, eo_event);
+ /*tcase_add_test(tc, eo_event);
tcase_add_test(tc, eo_event_call_in_call);
tcase_add_test(tc, eo_event_generation_bug);
- tcase_add_test(tc, eo_event_basic);
+ tcase_add_test(tc, eo_event_basic);*/
tcase_add_test(tc, eo_event_basic_order);
}