raster pushed a commit to branch efl-1.24.

http://git.enlightenment.org/core/efl.git/commit/?id=498af4b32da4ef668370d6c8a71c2b1a5eb9ad25

commit 498af4b32da4ef668370d6c8a71c2b1a5eb9ad25
Author: Marcel Hollerbach <[email protected]>
Date:   Wed Apr 29 11:47:05 2020 -0400

    elm_fileselector: support expandable items
    
    Summary:
    the fileselector can store exactly 1 model and monitor that for changes,
    which works normally just well. However, when we expand a items, another
    model comes into play, which is not monitored, and no additional
    reference is taken. Which means, _process_last will simply delete it,
    and elements that did not come into play at the _populate call are never
    displayed.
    
    With this commit, we check that we do not have a parent item, and
    explictly wait for the model to publish all its items, before we call
    _process_last.
    
    Additionally, that showed that the tracking of the list/grid item is
    ultimatly buggy, as there is no assertion that the parent model is
    really the parent directoy. Hence we need to hand pass the parent item
    here, as a fallback option to set the correct parent item.
    
    fixes T8689
    
    Reviewers: zmike
    
    Reviewed By: zmike
    
    Subscribers: zmike, cedric, #reviewers, #committers
    
    Tags: #efl
    
    Maniphest Tasks: T8689
    
    Differential Revision: https://phab.enlightenment.org/D11765
---
 src/lib/elementary/elc_fileselector.c | 38 +++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/src/lib/elementary/elc_fileselector.c 
b/src/lib/elementary/elc_fileselector.c
index eb107b14c6..01d4586b0e 100644
--- a/src/lib/elementary/elc_fileselector.c
+++ b/src/lib/elementary/elc_fileselector.c
@@ -880,7 +880,7 @@ _listing_request_cleanup(Listing_Request *lreq)
 }
 
 static void
-_process_model(Elm_Fileselector_Data *sd, Efl_Model *child)
+_process_model(Elm_Fileselector_Data *sd, Efl_Model *child, Elm_Object_Item 
*fallback_parent_item)
 {
    Elm_Fileselector_Item_Data *it_data;
    Elm_Object_Item *item, *it_parent;
@@ -927,6 +927,8 @@ _process_model(Elm_Fileselector_Data *sd, Efl_Model *child)
    it_data->is_dir = dir;
 
    it_parent = efl_key_data_get(parent, ".item.data");
+   if (!it_parent)
+     it_parent = fallback_parent_item;
 
    if (dir)
      {
@@ -981,7 +983,9 @@ _process_children_cb(Eo *model EINA_UNUSED, void *data, 
const Eina_Value v)
    if (!lreq->valid) goto end;
 
    EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
-     _process_model(lreq->sd, child);
+     {
+        _process_model(lreq->sd, child, lreq->parent_it);
+     }
 
    lreq->item_total = len;
 
@@ -1003,6 +1007,29 @@ _process_children_error(Eo *model EINA_UNUSED, void 
*data, Eina_Error error)
    return eina_value_error_init(error);
 }
 
+static void
+_count_changed_cb(void *data, const Efl_Event *ev EINA_UNUSED)
+{
+   Listing_Request *lreq = data;
+   Eina_Future *future;
+
+   efl_event_callback_del(lreq->model, EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, 
_count_changed_cb, lreq);
+
+   if (efl_model_children_count_get(lreq->model))
+     {
+        future = efl_model_children_slice_get(lreq->model, 0, 
efl_model_children_count_get(lreq->model));
+        future = efl_future_then(lreq->obj, future);
+        efl_future_then(lreq->model, future,
+                        .success = _process_children_cb,
+                        .error = _process_children_error,
+                        .data = lreq);
+     }
+   else
+     {
+        _process_last(lreq);
+     }
+}
+
 static void
 _populate(Evas_Object *obj,
           Efl_Model *model,
@@ -1087,7 +1114,10 @@ _populate(Evas_Object *obj,
      }
    else
      {
-        _process_last(lreq);
+        if (parent_it)
+          efl_event_callback_add(lreq->model, 
EFL_MODEL_EVENT_CHILDREN_COUNT_CHANGED, _count_changed_cb, lreq);
+        else
+          _process_last(lreq);
      }
 }
 
@@ -1624,7 +1654,7 @@ _resource_created_then(Eo *model EINA_UNUSED, void *data, 
const Eina_Value v)
    ELM_FILESELECTOR_DATA_GET(fs, sd);
 
    EINA_VALUE_ARRAY_FOREACH(&v, len, i, child)
-     _process_model(sd, child);
+     _process_model(sd, child, NULL); //this function will always just work 
for the root model of the fileselector
 
    return v;
 }

-- 


Reply via email to