summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-11-06 15:09:14 -0800
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-07 22:24:03 +0100
commit65955b7a9f84275c9ff799ef84cda6500c225bb1 (patch)
treed70fe5cfb64205350c80b0c09f8458e43861a4df
parentb77482e7d6846da1b1cceeda4811829400e921d0 (diff)
elementary: properly handle in flight request in Efl.Ui.CollectionView.
This fix adding item not always showing up in the CollectionView right away. The main issue comes down to the fact we can not chain a new request when one is already resolved partially. The code now make sure to properly do this. Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10614
-rw-r--r--src/lib/elementary/efl_ui_collection_view.c48
1 files changed, 23 insertions, 25 deletions
diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index 3b7b813..c08ae16 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -109,7 +109,7 @@ static const char *COLLECTION_VIEW_MANAGED_YES = "yes";
109#define MY_DATA_GET(obj, pd) \ 109#define MY_DATA_GET(obj, pd) \
110 Efl_Ui_Collection_View_Data *pd = efl_data_scope_get(obj, MY_CLASS); 110 Efl_Ui_Collection_View_Data *pd = efl_data_scope_get(obj, MY_CLASS);
111 111
112static void _entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request); 112static Eina_Bool _entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request);
113static void _idle_cb(void *data, const Efl_Event *event); 113static void _idle_cb(void *data, const Efl_Event *event);
114 114
115static int 115static int
@@ -435,10 +435,11 @@ _model_fetched_cb(Eo *obj, void *data, const Eina_Value v)
435 } 435 }
436 436
437 if (request_entity) 437 if (request_entity)
438 { 438 request->need_entity = EINA_TRUE;
439 request->need_entity = EINA_TRUE; 439
440 _entity_request(obj, request); 440 if (request->need_entity &&
441 } 441 !request->entity_requested)
442 _entity_request(obj, request);
442 443
443 return v; 444 return v;
444} 445}
@@ -449,12 +450,7 @@ _model_free_cb(Eo *o, void *data, const Eina_Future *dead_future EINA_UNUSED)
449 MY_DATA_GET(o, pd); 450 MY_DATA_GET(o, pd);
450 Efl_Ui_Collection_Request *request = data; 451 Efl_Ui_Collection_Request *request = data;
451 452
452 if (request->need_entity) 453 if (!request->entity_requested)
453 {
454 if (!request->entity_requested)
455 _entity_request(o, request);
456 }
457 else
458 { 454 {
459 pd->requests = eina_list_remove(pd->requests, request); 455 pd->requests = eina_list_remove(pd->requests, request);
460 free(request); 456 free(request);
@@ -632,7 +628,7 @@ _entity_fetched_cb(Eo *obj, void *data, const Eina_Value v)
632 { 628 {
633 efl_ui_position_manager_entity_item_size_changed(pd->manager, 629 efl_ui_position_manager_entity_item_size_changed(pd->manager,
634 updated_size_start_id, 630 updated_size_start_id,
635 i - 1); 631 request->offset + i - 1);
636 updated_size = EINA_FALSE; 632 updated_size = EINA_FALSE;
637 } 633 }
638 634
@@ -748,10 +744,11 @@ _cache_entity_fetch(Eina_List *requests, Efl_Ui_Collection_Request **request,
748 return requests; 744 return requests;
749} 745}
750 746
751static void 747static Eina_Bool
752_entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request) 748_entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request)
753{ 749{
754 if (request->model_requested && (!request->model_fetched)) return; 750 if (request->entity_requested) return EINA_TRUE;
751 if (request->model_fetched) return EINA_FALSE;
755 request->f = efl_future_then(obj, request->f, 752 request->f = efl_future_then(obj, request->f,
756 .success_type = EINA_VALUE_TYPE_ARRAY, 753 .success_type = EINA_VALUE_TYPE_ARRAY,
757 .success = _entity_fetch_cb); 754 .success = _entity_fetch_cb);
@@ -761,17 +758,19 @@ _entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request)
761 .data = request, 758 .data = request,
762 .free = _entity_free_cb); 759 .free = _entity_free_cb);
763 request->entity_requested = EINA_TRUE; 760 request->entity_requested = EINA_TRUE;
761 request->need_entity = EINA_TRUE;
762
763 return EINA_TRUE;
764} 764}
765 765
766static inline void 766static inline Eina_Bool
767_entity_inflight_request(Efl_Ui_Collection_View *obj, 767_entity_inflight_request(Efl_Ui_Collection_View *obj,
768 Efl_Ui_Collection_Request *request, 768 Efl_Ui_Collection_Request *request,
769 Efl_Ui_Collection_Request *inflight) 769 Efl_Ui_Collection_Request *inflight)
770{ 770{
771 if (request->need_entity == EINA_FALSE) return ; 771 if (request->need_entity == EINA_FALSE) return EINA_TRUE;
772 if (inflight->entity_requested) return ;
773 772
774 _entity_request(obj, inflight); 773 return _entity_request(obj, inflight);
775} 774}
776 775
777static Eina_List * 776static Eina_List *
@@ -804,7 +803,7 @@ _batch_request_flush(Eina_List *requests,
804 // request included in current inflight request 803 // request included in current inflight request
805 if (rstart >= istart && rend <= iend) 804 if (rstart >= istart && rend <= iend)
806 { 805 {
807 _entity_inflight_request(obj, request, inflight); 806 if (!_entity_inflight_request(obj, request, inflight)) continue;
808 807
809 // In this case no need to start a request 808 // In this case no need to start a request
810 requests = eina_list_remove_list(requests, ll); 809 requests = eina_list_remove_list(requests, ll);
@@ -816,6 +815,8 @@ _batch_request_flush(Eina_List *requests,
816 // request overflow left and right 815 // request overflow left and right
817 if (rstart < istart && iend < rend) 816 if (rstart < istart && iend < rend)
818 { 817 {
818 if (!_entity_inflight_request(obj, request, inflight)) continue;
819
819 // Remove the center portion of the request by emitting a new one 820 // Remove the center portion of the request by emitting a new one
820 Efl_Ui_Collection_Request *rn; 821 Efl_Ui_Collection_Request *rn;
821 822
@@ -830,24 +831,23 @@ _batch_request_flush(Eina_List *requests,
830 requests = eina_list_append(requests, rn); 831 requests = eina_list_append(requests, rn);
831 832
832 request->length = istart - rstart; 833 request->length = istart - rstart;
833 _entity_inflight_request(obj, request, inflight);
834 continue; 834 continue;
835 } 835 }
836 836
837 // request overflow left 837 // request overflow left
838 if (rstart < istart && rend > istart && rend <= iend) 838 if (rstart < istart && rend > istart && rend <= iend)
839 { 839 {
840 if (!_entity_inflight_request(obj, request, inflight)) continue;
840 request->length = istart - rstart; 841 request->length = istart - rstart;
841 _entity_inflight_request(obj, request, inflight);
842 continue; 842 continue;
843 } 843 }
844 844
845 // request overflow right 845 // request overflow right
846 if (rstart >= istart && rstart < iend && iend <= rend) 846 if (rstart >= istart && rstart < iend && iend <= rend)
847 { 847 {
848 if (!_entity_inflight_request(obj, request, inflight)) continue;
848 request->offset = iend; 849 request->offset = iend;
849 request->length = rend - iend; 850 request->length = rend - iend;
850 _entity_inflight_request(obj, request, inflight);
851 continue; 851 continue;
852 } 852 }
853 } 853 }
@@ -891,7 +891,7 @@ _batch_request_flush(Eina_List *requests,
891 891
892 eina_list_move_list(&pd->requests, &requests, ll); 892 eina_list_move_list(&pd->requests, &requests, ll);
893 } 893 }
894 return NULL; 894 return eina_list_free(requests);
895} 895}
896 896
897static Efl_Ui_Position_Manager_Size_Batch_Result 897static Efl_Ui_Position_Manager_Size_Batch_Result
@@ -1110,7 +1110,6 @@ _batch_entity_cb(void *data, Efl_Ui_Position_Manager_Request_Range range, Eina_R
1110 1110
1111 requests = _cache_entity_fetch(requests, &request, pd, 1111 requests = _cache_entity_fetch(requests, &request, pd,
1112 search_index, &entities[idx]); 1112 search_index, &entities[idx]);
1113
1114 idx++; 1113 idx++;
1115 } 1114 }
1116 // Done, but flush request first 1115 // Done, but flush request first
@@ -1772,7 +1771,6 @@ _efl_model_child_added(void *data, const Efl_Event *event)
1772 1771
1773 notify_manager: 1772 notify_manager:
1774#endif 1773#endif
1775 // FIXME this function must be called with an entity
1776 efl_ui_position_manager_entity_item_added(pd->manager, ev->index, NULL); 1774 efl_ui_position_manager_entity_item_added(pd->manager, ev->index, NULL);
1777} 1775}
1778 1776