cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=13b230029df72120191bbd837b065e2610a3c3ed

commit 13b230029df72120191bbd837b065e2610a3c3ed
Author: Cedric BAIL <cedric.b...@free.fr>
Date:   Thu Apr 18 09:57:53 2019 -0700

    ecore: use new infrastructure for Efl.CompositeModel to only have one Model 
object represent its data at any point in time.
    
    Reviewed-by: Marcel Hollerbach <m...@marcel-hollerbach.de>
    Differential Revision: https://phab.enlightenment.org/D8660
---
 src/lib/ecore/efl_composite_model.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/lib/ecore/efl_composite_model.c 
b/src/lib/ecore/efl_composite_model.c
index a0457729ac..7ef607edd2 100644
--- a/src/lib/ecore/efl_composite_model.c
+++ b/src/lib/ecore/efl_composite_model.c
@@ -252,6 +252,20 @@ struct _Efl_Composite_Model_Slice_Request
    unsigned int dummy_need;
 };
 
+static Efl_Model *
+_efl_composite_lookup(const Efl_Class *self, Eo *parent, Efl_Model *view, 
unsigned int index)
+{
+   EFL_COMPOSITE_LOOKUP_RETURN(remember, parent, view, "_efl.composite_model");
+
+   remember = efl_add_ref(self, parent,
+                          efl_ui_view_model_set(efl_added, view),
+                          efl_composite_model_index_set(efl_added, index),
+                          efl_loop_model_volatile_make(efl_added));
+   if (!remember) return NULL;
+
+   EFL_COMPOSITE_REMEMBER_RETURN(remember, view);
+}
+
 static Eina_Value
 _efl_composite_model_then(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
 {
@@ -266,13 +280,8 @@ _efl_composite_model_then(Eo *o EINA_UNUSED, void *data, 
const Eina_Value v)
      {
         Eo *composite;
 
-        // First set the Model to be used as a source so that we the newly 
object
-        // can know if it needs to retain the information regarding its index.
-        composite = efl_add_ref(req->self, req->parent,
-                                efl_ui_view_model_set(efl_added, target),
-                                efl_composite_model_index_set(efl_added, 
req->start + i),
-                                efl_loop_model_volatile_make(efl_added));
-
+        // Fetch an existing composite model for this model or create a new 
one if none exist
+        composite = _efl_composite_lookup(req->self, req->parent, target, 
req->start + i);
         eina_value_array_append(&r, composite);
         // Dropping this scope reference
         efl_unref(composite);

-- 


Reply via email to