summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-04 10:51:01 +0900
committerHermet Park <hermetpark@gmail.com>2018-07-04 10:53:09 +0900
commitb0e0fcf3d60eac53229ce107b01c6d31ce8aa817 (patch)
tree31b83f31920fe6da8e99f10c0e44496c069bc911
parentf3512bec57925a4ee9091eb375fac043bf3ecf9e (diff)
evas: add more error messages when passing invalid objects to evas callbacks
Summary: this should only happen if the user has made a mistake regarding the existence or type of an object, so ensure that an error message occurs to help debug any failures which result fix T6326 Reviewers: bu5hm4n, Hermet, woohyun, devilhorns Reviewed By: Hermet Subscribers: cedric, #committers Tags: #efl Maniphest Tasks: T6326 Differential Revision: https://phab.enlightenment.org/D6322
-rw-r--r--src/lib/evas/canvas/evas_callbacks.c81
1 files changed, 57 insertions, 24 deletions
diff --git a/src/lib/evas/canvas/evas_callbacks.c b/src/lib/evas/canvas/evas_callbacks.c
index b9da12bccb..0814b6fa5b 100644
--- a/src/lib/evas/canvas/evas_callbacks.c
+++ b/src/lib/evas/canvas/evas_callbacks.c
@@ -471,12 +471,17 @@ evas_object_event_callback_add(Evas_Object *eo_obj, Evas_Callback_Type type, Eva
471EAPI void 471EAPI void
472evas_object_event_callback_priority_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Object_Event_Cb func, const void *data) 472evas_object_event_callback_priority_add(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Object_Event_Cb func, const void *data)
473{ 473{
474 Evas_Object_Protected_Data *obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 474 Evas_Object_Protected_Data *obj;
475 Evas_Event_Cb_Wrapper_Info *cb_info; 475 Evas_Event_Cb_Wrapper_Info *cb_info;
476 const Efl_Event_Description *desc; 476 const Efl_Event_Description *desc;
477 477
478 if (!obj) return; 478 EINA_SAFETY_ON_NULL_RETURN(eo_obj);
479 if (!func) return; 479 EINA_SAFETY_ON_NULL_RETURN(func);
480
481 EINA_SAFETY_ON_TRUE_RETURN(efl_invalidated_get(eo_obj));
482
483 obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
484 EINA_SAFETY_ON_NULL_RETURN(obj);
480 485
481 cb_info = calloc(1, sizeof(*cb_info)); 486 cb_info = calloc(1, sizeof(*cb_info));
482 cb_info->func.object_cb = func; 487 cb_info->func.object_cb = func;
@@ -494,11 +499,14 @@ evas_object_event_callback_priority_add(Evas_Object *eo_obj, Evas_Callback_Type
494EAPI void * 499EAPI void *
495evas_object_event_callback_del(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func) 500evas_object_event_callback_del(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func)
496{ 501{
497 Evas_Object_Protected_Data *obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 502 Evas_Object_Protected_Data *obj;
498 Evas_Event_Cb_Wrapper_Info *info; 503 Evas_Event_Cb_Wrapper_Info *info;
499 504
500 if (!obj) return NULL; 505 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_obj, NULL);
501 if (!func) return NULL; 506 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
507
508 obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
509 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
502 510
503 if (!obj->callbacks) return NULL; 511 if (!obj->callbacks) return NULL;
504 512
@@ -521,11 +529,14 @@ evas_object_event_callback_del(Evas_Object *eo_obj, Evas_Callback_Type type, Eva
521EAPI void * 529EAPI void *
522evas_object_event_callback_del_full(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) 530evas_object_event_callback_del_full(Evas_Object *eo_obj, Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data)
523{ 531{
524 Evas_Object_Protected_Data *obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 532 Evas_Object_Protected_Data *obj;
525 Evas_Event_Cb_Wrapper_Info *info; 533 Evas_Event_Cb_Wrapper_Info *info;
526 534
527 if (!obj) return NULL; 535 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_obj, NULL);
528 if (!func) return NULL; 536 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
537
538 obj = efl_data_scope_safe_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
539 EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
529 540
530 if (!obj->callbacks) return NULL; 541 if (!obj->callbacks) return NULL;
531 542
@@ -555,12 +566,17 @@ evas_event_callback_add(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func,
555EAPI void 566EAPI void
556evas_event_callback_priority_add(Evas *eo_e, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Event_Cb func, const void *data) 567evas_event_callback_priority_add(Evas *eo_e, Evas_Callback_Type type, Evas_Callback_Priority priority, Evas_Event_Cb func, const void *data)
557{ 568{
558 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 569 Evas_Public_Data *e;
559 Evas_Event_Cb_Wrapper_Info *cb_info; 570 Evas_Event_Cb_Wrapper_Info *cb_info;
560 const Efl_Event_Description *desc; 571 const Efl_Event_Description *desc;
561 572
562 if (!e) return; 573 EINA_SAFETY_ON_NULL_RETURN(eo_e);
563 if (!func) return; 574 EINA_SAFETY_ON_NULL_RETURN(func);
575
576 EINA_SAFETY_ON_TRUE_RETURN(efl_invalidated_get(eo_e));
577
578 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
579 EINA_SAFETY_ON_NULL_RETURN(e);
564 580
565 cb_info = calloc(1, sizeof(*cb_info)); 581 cb_info = calloc(1, sizeof(*cb_info));
566 cb_info->func.evas_cb = func; 582 cb_info->func.evas_cb = func;
@@ -577,11 +593,14 @@ evas_event_callback_priority_add(Evas *eo_e, Evas_Callback_Type type, Evas_Callb
577EAPI void * 593EAPI void *
578evas_event_callback_del(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func) 594evas_event_callback_del(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func)
579{ 595{
580 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 596 Evas_Public_Data *e;
581 Evas_Event_Cb_Wrapper_Info *info; 597 Evas_Event_Cb_Wrapper_Info *info;
582 598
583 if (!e) return NULL; 599 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_e, NULL);
584 if (!func) return NULL; 600 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
601
602 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
603 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
585 604
586 if (!e->callbacks) return NULL; 605 if (!e->callbacks) return NULL;
587 606
@@ -604,11 +623,14 @@ evas_event_callback_del(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func)
604EAPI void * 623EAPI void *
605evas_event_callback_del_full(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data) 624evas_event_callback_del_full(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb func, const void *data)
606{ 625{
607 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 626 Evas_Public_Data *e;
608 Evas_Event_Cb_Wrapper_Info *info; 627 Evas_Event_Cb_Wrapper_Info *info;
609 628
610 if (!e) return NULL; 629 EINA_SAFETY_ON_NULL_RETURN_VAL(eo_e, NULL);
611 if (!func) return NULL; 630 EINA_SAFETY_ON_NULL_RETURN_VAL(func, NULL);
631
632 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
633 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
612 634
613 if (!e->callbacks) return NULL; 635 if (!e->callbacks) return NULL;
614 636
@@ -631,10 +653,15 @@ evas_event_callback_del_full(Evas *eo_e, Evas_Callback_Type type, Evas_Event_Cb
631EAPI void 653EAPI void
632evas_post_event_callback_push(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data) 654evas_post_event_callback_push(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data)
633{ 655{
634 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 656 Evas_Public_Data *e;
635 Evas_Post_Callback *pc; 657 Evas_Post_Callback *pc;
636 658
637 if (!e || e->delete_me) return; 659 EINA_SAFETY_ON_NULL_RETURN(eo_e);
660 EINA_SAFETY_ON_TRUE_RETURN(efl_invalidated_get(eo_e));
661
662 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
663 EINA_SAFETY_ON_NULL_RETURN(e);
664 if (e->delete_me) return;
638 if (e->current_event == EVAS_CALLBACK_LAST) 665 if (e->current_event == EVAS_CALLBACK_LAST)
639 { 666 {
640 ERR("%s() can only be called from an input event callback!", __FUNCTION__); 667 ERR("%s() can only be called from an input event callback!", __FUNCTION__);
@@ -655,11 +682,14 @@ evas_post_event_callback_push(Evas *eo_e, Evas_Object_Event_Post_Cb func, const
655EAPI void 682EAPI void
656evas_post_event_callback_remove(Evas *eo_e, Evas_Object_Event_Post_Cb func) 683evas_post_event_callback_remove(Evas *eo_e, Evas_Object_Event_Post_Cb func)
657{ 684{
658 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 685 Evas_Public_Data *e;
659 Evas_Post_Callback *pc; 686 Evas_Post_Callback *pc;
660 Eina_List *l; 687 Eina_List *l;
661 688
662 if (!e) return; 689 EINA_SAFETY_ON_NULL_RETURN(eo_e);
690
691 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
692 EINA_SAFETY_ON_NULL_RETURN(e);
663 EINA_LIST_FOREACH(e->post_events, l, pc) 693 EINA_LIST_FOREACH(e->post_events, l, pc)
664 { 694 {
665 if (pc->func == func) 695 if (pc->func == func)
@@ -673,11 +703,14 @@ evas_post_event_callback_remove(Evas *eo_e, Evas_Object_Event_Post_Cb func)
673EAPI void 703EAPI void
674evas_post_event_callback_remove_full(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data) 704evas_post_event_callback_remove_full(Evas *eo_e, Evas_Object_Event_Post_Cb func, const void *data)
675{ 705{
676 Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); 706 Evas_Public_Data *e;
677 Evas_Post_Callback *pc; 707 Evas_Post_Callback *pc;
678 Eina_List *l; 708 Eina_List *l;
679 709
680 if (!e) return; 710 EINA_SAFETY_ON_NULL_RETURN(eo_e);
711
712 e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS);
713 EINA_SAFETY_ON_NULL_RETURN(e);
681 EINA_LIST_FOREACH(e->post_events, l, pc) 714 EINA_LIST_FOREACH(e->post_events, l, pc)
682 { 715 {
683 if ((pc->func == func) && (pc->data == data)) 716 if ((pc->func == func) && (pc->data == data))