summaryrefslogtreecommitdiff
path: root/src/lib/eldbus
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-02-13 10:46:31 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-03-08 14:31:06 -0800
commit6bb197caa9181f6c2639ecd25649a8237c158dd4 (patch)
tree1bc294f616466547546185dadf4e3202a31ed6ab /src/lib/eldbus
parent98e5a71974553dced24c6858d61d183ecc5b5b29 (diff)
efl: for consistency and effiency move Efl.Model event to send stringshare like Property_Bind event.
Reviewed-by: Vitor Sousa da Silva <vitorsousa@expertisesolutions.com.br> Differential Revision: https://phab.enlightenment.org/D7946
Diffstat (limited to 'src/lib/eldbus')
-rw-r--r--src/lib/eldbus/eldbus_model_proxy.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib/eldbus/eldbus_model_proxy.c b/src/lib/eldbus/eldbus_model_proxy.c
index 32253e3..d571732 100644
--- a/src/lib/eldbus/eldbus_model_proxy.c
+++ b/src/lib/eldbus/eldbus_model_proxy.c
@@ -530,6 +530,7 @@ _eldbus_model_proxy_property_get_all_load(const Eldbus_Message *msg, Eldbus_Mode
530 Eldbus_Message_Iter *values = NULL; 530 Eldbus_Message_Iter *values = NULL;
531 Eldbus_Message_Iter *entry; 531 Eldbus_Message_Iter *entry;
532 Eina_Array *changed_properties; 532 Eina_Array *changed_properties;
533 Eina_Stringshare *tmp = NULL;
533 const char *error_name, *error_text; 534 const char *error_name, *error_text;
534 535
535 if (eldbus_message_error_get(msg, &error_name, &error_text)) 536 if (eldbus_message_error_get(msg, &error_name, &error_text))
@@ -547,7 +548,6 @@ _eldbus_model_proxy_property_get_all_load(const Eldbus_Message *msg, Eldbus_Mode
547 changed_properties = eina_array_new(1); 548 changed_properties = eina_array_new(1);
548 while (eldbus_message_iter_get_and_next(values, 'e', &entry)) 549 while (eldbus_message_iter_get_and_next(values, 'e', &entry))
549 { 550 {
550 Eina_Stringshare *tmp;
551 const char *property; 551 const char *property;
552 Eldbus_Message_Iter *variant; 552 Eldbus_Message_Iter *variant;
553 Eina_Value *struct_value; 553 Eina_Value *struct_value;
@@ -567,7 +567,6 @@ _eldbus_model_proxy_property_get_all_load(const Eldbus_Message *msg, Eldbus_Mode
567 567
568 tmp = eina_stringshare_add(property); 568 tmp = eina_stringshare_add(property);
569 prop_value = eina_hash_find(pd->properties, tmp); 569 prop_value = eina_hash_find(pd->properties, tmp);
570 eina_stringshare_del(tmp);
571 if (!prop_value) goto on_error; 570 if (!prop_value) goto on_error;
572 571
573 ret = eina_value_copy(&arg0, prop_value); 572 ret = eina_value_copy(&arg0, prop_value);
@@ -575,14 +574,20 @@ _eldbus_model_proxy_property_get_all_load(const Eldbus_Message *msg, Eldbus_Mode
575 574
576 eina_value_flush(&arg0); 575 eina_value_flush(&arg0);
577 576
578 ret = eina_array_push(changed_properties, property); 577 ret = eina_array_push(changed_properties, tmp);
579 if (!ret) goto on_error; 578 if (!ret) goto on_error;
579
580 // Reset tmp to NULL to avoid double free.
581 tmp = NULL;
580 } 582 }
581 583
582 pd->is_loaded = EINA_TRUE; 584 pd->is_loaded = EINA_TRUE;
583 return changed_properties; 585 return changed_properties;
584 586
585 on_error: 587 on_error:
588 eina_stringshare_del(tmp);
589 while ((tmp = eina_array_pop(changed_properties)))
590 eina_stringshare_del(tmp);
586 eina_array_free(changed_properties); 591 eina_array_free(changed_properties);
587 return NULL; 592 return NULL;
588} 593}
@@ -603,6 +608,7 @@ _eldbus_model_proxy_property_get_all_cb(void *data,
603{ 608{
604 Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data; 609 Eldbus_Model_Proxy_Data *pd = (Eldbus_Model_Proxy_Data*)data;
605 Eldbus_Property_Promise* p; 610 Eldbus_Property_Promise* p;
611 Eina_Stringshare *sp;
606 Eina_Array *properties; 612 Eina_Array *properties;
607 Efl_Model_Property_Event evt; 613 Efl_Model_Property_Event evt;
608 614
@@ -623,6 +629,8 @@ _eldbus_model_proxy_property_get_all_cb(void *data,
623 629
624 evt.changed_properties = properties; 630 evt.changed_properties = properties;
625 efl_event_callback_call(pd->obj, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &evt); 631 efl_event_callback_call(pd->obj, EFL_MODEL_EVENT_PROPERTIES_CHANGED, &evt);
632 while ((sp = eina_array_pop(properties)))
633 eina_stringshare_del(sp);
626 eina_array_free(properties); 634 eina_array_free(properties);
627} 635}
628 636
@@ -635,6 +643,7 @@ _eldbus_model_proxy_property_set_load_cb(void *data,
635 Eldbus_Model_Proxy_Property_Set_Data *set_data = (Eldbus_Model_Proxy_Property_Set_Data *)data; 643 Eldbus_Model_Proxy_Property_Set_Data *set_data = (Eldbus_Model_Proxy_Property_Set_Data *)data;
636 Eldbus_Model_Proxy_Data *pd = set_data->pd; 644 Eldbus_Model_Proxy_Data *pd = set_data->pd;
637 Eina_Array *properties; 645 Eina_Array *properties;
646 Eina_Stringshare *sp;
638 const char *signature; 647 const char *signature;
639 648
640 pd->pendings = eina_list_remove(pd->pendings, pending); 649 pd->pendings = eina_list_remove(pd->pendings, pending);
@@ -645,16 +654,18 @@ _eldbus_model_proxy_property_set_load_cb(void *data,
645 if (!signature || !properties) 654 if (!signature || !properties)
646 { 655 {
647 eina_promise_reject(set_data->promise, EFL_MODEL_ERROR_UNKNOWN); 656 eina_promise_reject(set_data->promise, EFL_MODEL_ERROR_UNKNOWN);
648 eina_array_free(properties);
649 _eldbus_model_proxy_property_set_data_free(set_data); 657 _eldbus_model_proxy_property_set_data_free(set_data);
650 return; 658 goto end;
651 } 659 }
652 660
653 eina_array_free(properties);
654 pending = eldbus_proxy_property_value_set(pd->proxy, set_data->property, 661 pending = eldbus_proxy_property_value_set(pd->proxy, set_data->property,
655 signature, set_data->value, 662 signature, set_data->value,
656 _eldbus_model_proxy_property_set_cb, set_data); 663 _eldbus_model_proxy_property_set_cb, set_data);
657 pd->pendings = eina_list_append(pd->pendings, pending); 664 pd->pendings = eina_list_append(pd->pendings, pending);
665 end:
666 while ((sp = eina_array_pop(properties)))
667 eina_stringshare_del(sp);
668 eina_array_free(properties);
658} 669}
659 670
660 671