summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-11-07 16:14:44 -0800
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2019-11-13 21:16:07 +0100
commitf71a109e70b7a952cbac204d78f4142350083892 (patch)
treede657ed647b8d00f284d9c1d1b2c7d5fc79116af
parent560db3957792b0dc5ca90076e88cab09b4cb877b (diff)
elementary: fix recursive case during model fetch in Efl.Ui.CollectionView.
Figuring out why model fetch was sometime not working recursively allow to reduce the amount of request that need to be made. In this case, notifying the position manager or lack of notification was triggering a case where the item would not show up (Joice of nested asynchronous behavior). Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D10624
-rw-r--r--src/lib/elementary/efl_ui_collection_view.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/lib/elementary/efl_ui_collection_view.c b/src/lib/elementary/efl_ui_collection_view.c
index 16680e8..8d8b215 100644
--- a/src/lib/elementary/efl_ui_collection_view.c
+++ b/src/lib/elementary/efl_ui_collection_view.c
@@ -57,8 +57,7 @@ struct _Efl_Ui_Collection_Request
57 uint64_t offset; 57 uint64_t offset;
58 uint64_t length; 58 uint64_t length;
59 59
60 Eina_Bool model_requested : 1; 60 Eina_Bool need_size : 1;
61 Eina_Bool model_fetched : 1;
62 Eina_Bool need_entity : 1; 61 Eina_Bool need_entity : 1;
63 Eina_Bool entity_requested : 1; 62 Eina_Bool entity_requested : 1;
64}; 63};
@@ -352,6 +351,7 @@ _request_add(Eina_List *requests, Efl_Ui_Collection_Request **request,
352 if ((*request)->offset + (*request)->length == index) 351 if ((*request)->offset + (*request)->length == index)
353 { 352 {
354 if (need_entity) (*request)->need_entity = EINA_TRUE; 353 if (need_entity) (*request)->need_entity = EINA_TRUE;
354 if (!need_entity) (*request)->need_size = EINA_TRUE;
355 (*request)->length += 1; 355 (*request)->length += 1;
356 return requests; 356 return requests;
357 } 357 }
@@ -364,8 +364,8 @@ _request_add(Eina_List *requests, Efl_Ui_Collection_Request **request,
364 (*request)->offset = index; 364 (*request)->offset = index;
365 (*request)->length = 1; 365 (*request)->length = 1;
366 // At this point, we rely on the model caching ability to avoid recreating model 366 // At this point, we rely on the model caching ability to avoid recreating model
367 (*request)->model_requested = EINA_TRUE;
368 (*request)->need_entity = !!need_entity; 367 (*request)->need_entity = !!need_entity;
368 (*request)->need_size = EINA_TRUE;
369 369
370 return requests; 370 return requests;
371} 371}
@@ -379,7 +379,6 @@ _model_fetched_cb(Eo *obj, void *data, const Eina_Value v)
379 unsigned int i, len; 379 unsigned int i, len;
380 Eina_Bool request_entity = EINA_FALSE; 380 Eina_Bool request_entity = EINA_FALSE;
381 381
382 request->model_fetched = EINA_TRUE;
383 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child) 382 EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
384 { 383 {
385 Efl_Ui_Collection_Item_Lookup *insert; 384 Efl_Ui_Collection_Item_Lookup *insert;
@@ -435,11 +434,17 @@ _model_fetched_cb(Eo *obj, void *data, const Eina_Value v)
435 } 434 }
436 435
437 if (request_entity) 436 if (request_entity)
438 request->need_entity = EINA_TRUE; 437 {
438 request->need_entity = EINA_TRUE;
439 439
440 if (request->need_entity && 440 if (!request->entity_requested)
441 !request->entity_requested) 441 _entity_request(obj, request);
442 _entity_request(obj, request); 442 }
443 else if (request->need_size)
444 {
445 efl_ui_position_manager_entity_item_size_changed(pd->manager, request->offset,
446 request->offset + len);
447 }
443 448
444 return v; 449 return v;
445} 450}
@@ -624,7 +629,7 @@ _entity_fetched_cb(Eo *obj, void *data, const Eina_Value v)
624 629
625 // Currently position manager will flush its entire size cache on update, so only do 630 // Currently position manager will flush its entire size cache on update, so only do
626 // it when necessary to improve performance. 631 // it when necessary to improve performance.
627 if (updated_size) 632 if (updated_size || request->need_size)
628 { 633 {
629 efl_ui_position_manager_entity_item_size_changed(pd->manager, 634 efl_ui_position_manager_entity_item_size_changed(pd->manager,
630 updated_size_start_id, 635 updated_size_start_id,
@@ -748,7 +753,6 @@ static Eina_Bool
748_entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request) 753_entity_request(Efl_Ui_Collection_View *obj, Efl_Ui_Collection_Request *request)
749{ 754{
750 if (request->entity_requested) return EINA_TRUE; 755 if (request->entity_requested) return EINA_TRUE;
751 if (request->model_fetched) return EINA_FALSE;
752 request->f = efl_future_then(obj, request->f, 756 request->f = efl_future_then(obj, request->f,
753 .success_type = EINA_VALUE_TYPE_ARRAY, 757 .success_type = EINA_VALUE_TYPE_ARRAY,
754 .success = _entity_fetch_cb); 758 .success = _entity_fetch_cb);
@@ -768,6 +772,7 @@ _entity_inflight_request(Efl_Ui_Collection_View *obj,
768 Efl_Ui_Collection_Request *request, 772 Efl_Ui_Collection_Request *request,
769 Efl_Ui_Collection_Request *inflight) 773 Efl_Ui_Collection_Request *inflight)
770{ 774{
775 inflight->need_size |= request->need_size;
771 if (request->need_entity == EINA_FALSE) return EINA_TRUE; 776 if (request->need_entity == EINA_FALSE) return EINA_TRUE;
772 777
773 return _entity_request(obj, inflight); 778 return _entity_request(obj, inflight);
@@ -825,8 +830,8 @@ _batch_request_flush(Eina_List *requests,
825 830
826 rn->offset = iend; 831 rn->offset = iend;
827 rn->length = rend - iend; 832 rn->length = rend - iend;
828 rn->model_requested = request->model_requested;
829 rn->need_entity = request->need_entity; 833 rn->need_entity = request->need_entity;
834 rn->need_size = request->need_size;
830 835
831 requests = eina_list_append(requests, rn); 836 requests = eina_list_append(requests, rn);
832 837
@@ -877,12 +882,6 @@ _batch_request_flush(Eina_List *requests,
877 882
878 // We now have a request, time to trigger a fetch 883 // We now have a request, time to trigger a fetch
879 // We assume here that we are always fetching the model (model_requested must be true) 884 // We assume here that we are always fetching the model (model_requested must be true)
880 if (!request->model_requested)
881 {
882 CRI("Someone forgot to set model_requested for %" PRIu64 " to %" PRIu64 ".",
883 request->offset, request->offset + request->length);
884 request->model_requested = EINA_TRUE;
885 }
886 request->f = efl_model_children_slice_get(model, request->offset, request->length); 885 request->f = efl_model_children_slice_get(model, request->offset, request->length);
887 request->f = efl_future_then(obj, request->f, 886 request->f = efl_future_then(obj, request->f,
888 .success = _model_fetched_cb, 887 .success = _model_fetched_cb,
@@ -1532,7 +1531,7 @@ _manager_content_visible_range_changed_cb(void *data, const Efl_Event *ev)
1532 request->offset = lowerlimit_offset; 1531 request->offset = lowerlimit_offset;
1533 // This length work over multiple viewport as they are contiguous 1532 // This length work over multiple viewport as they are contiguous
1534 request->length = lowerlimit_offset - pd->viewport[0]->offset; 1533 request->length = lowerlimit_offset - pd->viewport[0]->offset;
1535 request->model_requested = EINA_TRUE; 1534 request->need_size = EINA_TRUE;
1536 request->need_entity = EINA_TRUE; 1535 request->need_entity = EINA_TRUE;
1537 1536
1538 requests = eina_list_append(requests, request); 1537 requests = eina_list_append(requests, request);
@@ -1549,7 +1548,7 @@ _manager_content_visible_range_changed_cb(void *data, const Efl_Event *ev)
1549 request->offset = upperlimit_offset; 1548 request->offset = upperlimit_offset;
1550 // This length work over multiple viewport as they are contiguous 1549 // This length work over multiple viewport as they are contiguous
1551 request->length = pd->viewport[2]->offset + pd->viewport[2]->count - upperlimit_offset; 1550 request->length = pd->viewport[2]->offset + pd->viewport[2]->count - upperlimit_offset;
1552 request->model_requested = EINA_TRUE; 1551 request->need_size = EINA_TRUE;
1553 request->need_entity = EINA_TRUE; 1552 request->need_entity = EINA_TRUE;
1554 1553
1555 requests = eina_list_append(requests, request); 1554 requests = eina_list_append(requests, request);
@@ -1759,7 +1758,7 @@ _efl_model_child_added(void *data, const Efl_Event *event)
1759 if (!request) break; 1758 if (!request) break;
1760 request->offset = ev->index; 1759 request->offset = ev->index;
1761 request->length = 1; 1760 request->length = 1;
1762 request->model_requested = EINA_TRUE; 1761 request->need_size = EINA_TRUE;
1763 request->need_entity = EINA_TRUE; 1762 request->need_entity = EINA_TRUE;
1764 1763
1765 requests = eina_list_append(requests, request); 1764 requests = eina_list_append(requests, request);
@@ -1839,7 +1838,7 @@ _efl_model_child_removed(void *data, const Efl_Event *event)
1839 if (!request) break; 1838 if (!request) break;
1840 request->offset = pd->viewport[2]->offset + pd->viewport[i]->count - 1; 1839 request->offset = pd->viewport[2]->offset + pd->viewport[i]->count - 1;
1841 request->length = 1; 1840 request->length = 1;
1842 request->model_requested = EINA_TRUE; 1841 request->need_size = EINA_TRUE;
1843 request->need_entity = EINA_TRUE; 1842 request->need_entity = EINA_TRUE;
1844 1843
1845 requests = eina_list_append(requests, request); 1844 requests = eina_list_append(requests, request);
@@ -1972,7 +1971,7 @@ _efl_ui_collection_view_model_changed(void *data, const Efl_Event *event)
1972 1971
1973 request->offset = pd->viewport[i]->offset; 1972 request->offset = pd->viewport[i]->offset;
1974 request->length = pd->viewport[i]->count; 1973 request->length = pd->viewport[i]->count;
1975 request->model_requested = EINA_TRUE; 1974 request->need_size = EINA_TRUE;
1976 request->need_entity = EINA_TRUE; 1975 request->need_entity = EINA_TRUE;
1977 1976
1978 requests = eina_list_append(requests, request); 1977 requests = eina_list_append(requests, request);