Hello,

On Fri, Jun 17, 2016 at 02:27:55PM -0700, Vitor Sousa wrote:
> vitorsousa pushed a commit to branch master.
> 
> http://git.enlightenment.org/core/efl.git/commit/?id=434421021d3dfd808ff8f76a4279b1e476376376
> 
> commit 434421021d3dfd808ff8f76a4279b1e476376376
> Author: Vitor Sousa <[email protected]>
> Date:   Fri Jun 17 16:40:49 2016 -0300
> 
>     elementary: Fix fileselector directory monitoring events
>     
>     @fix
> ---
>  src/lib/elementary/elc_fileselector.c        | 58 
> ++++++++++++++++++++--------
>  src/lib/elementary/elm_widget_fileselector.h |  1 +
>  2 files changed, 42 insertions(+), 17 deletions(-)
> 
> diff --git a/src/lib/elementary/elc_fileselector.c 
> b/src/lib/elementary/elc_fileselector.c
> index 4c510b8..d3053a7 100644
> --- a/src/lib/elementary/elc_fileselector.c
> +++ b/src/lib/elementary/elc_fileselector.c
> @@ -74,12 +74,27 @@ _model_free_eo_cb(void *data)
>  }
>  
>  static void
> +_monitoring_start(Elm_Fileselector *fs, Elm_Fileselector_Data *sd, Efl_Model 
> *model)
> +{
> +   sd->monitoring = EINA_TRUE;
> +   eo_event_callback_add(model, EFL_MODEL_EVENT_CHILD_ADDED, 
> _resource_created, fs);
> +   eo_event_callback_add(model, EFL_MODEL_EVENT_CHILD_REMOVED, 
> _resource_deleted, fs);

You could have used a array here, so its less likly to miss a callback
at _monitoring_stop.

> +}
> +
> +static void
> +_monitoring_stop(Elm_Fileselector *fs, Elm_Fileselector_Data *sd, Efl_Model 
> *model)
> +{
> +   sd->monitoring = EINA_FALSE;
> +   eo_event_callback_del(model, EFL_MODEL_EVENT_CHILD_ADDED, 
> _resource_created, fs);
> +   eo_event_callback_del(model, EFL_MODEL_EVENT_CHILD_REMOVED, 
> _resource_deleted, fs);
> +}
> +
> +static void
>  _elm_fileselector_replace_model(Elm_Fileselector *fs, Elm_Fileselector_Data 
> *sd, Efl_Model *model, const char *path)
>  {
>     if (sd->model)
>       {
> -        eo_event_callback_del(sd->model, EFL_MODEL_EVENT_CHILD_ADDED, 
> _resource_created, fs);
> -        eo_event_callback_del(sd->model, EFL_MODEL_EVENT_CHILD_REMOVED, 
> _resource_deleted, fs);
> +        _monitoring_stop(fs, sd, sd->model);
>          eo_unref(sd->model);
>       }
>  
> @@ -87,8 +102,7 @@ _elm_fileselector_replace_model(Elm_Fileselector *fs, 
> Elm_Fileselector_Data *sd,
>       {
>          sd->model = model ? eo_ref(model) : NULL;
>          eina_stringshare_replace(&sd->path, path);
> -        eo_event_callback_add(sd->model, EFL_MODEL_EVENT_CHILD_ADDED, 
> _resource_created, fs);
> -        eo_event_callback_add(sd->model, EFL_MODEL_EVENT_CHILD_REMOVED, 
> _resource_deleted, fs);
> +        _monitoring_start(fs, sd, sd->model);
>          /* TODO: sub directory should be monitored for expand mode */
>       }
>     else
> @@ -902,6 +916,9 @@ _populate(Evas_Object *obj,
>          sd->current_populate_lreq = NULL;
>       }
>  
> +   if (sd->model)
> +     _monitoring_stop(obj, sd, sd->model);
> +
>     lreq = calloc(1, sizeof (Listing_Request));
>     if (!lreq) return;
>  
> @@ -1660,6 +1677,9 @@ _resource_created_then(void *data, void *values)
>  
>     ELM_FILESELECTOR_DATA_GET(obj, sd);
>  
> +   if (!sd || !sd->monitoring || sd->model != it_data->parent_model)
> +     goto cancel;
> +
>     if (!_iterator_next_value_get(value_itt, &path) ||
>         !_iterator_next_value_get(value_itt, &filename) ||
>         !path || !filename ||
> @@ -1669,25 +1689,17 @@ _resource_created_then(void *data, void *values)
>         !_iterator_next_value_get(value_itt, &mime_type))
>       {
>          ERR("missing Efl.Model data");
> -        eo_unref(it_data->model);
> -        free(it_data);
> -        goto end;
> +        goto cancel;
>       }
>  
>     if (!_filter_child(sd, path, filename, dir, mime_type))
> -     {
> -        eo_unref(it_data->model);
> -        free(it_data);
> -        goto end;
> -     }
> +     goto cancel;
>  
>     it_data->path = eina_stringshare_add(path);
>     it_data->filename = eina_stringshare_add(filename);
>     it_data->size = size;
>     it_data->mtime = mtime;
>     it_data->mime_type = eina_stringshare_add(mime_type);
> -   it_data->parent_model = eo_ref(sd->model);
> -   it_data->parent_path = eina_stringshare_add(sd->path);
>     it_data->is_dir = dir;
>  
>     if (dir)
> @@ -1710,8 +1722,15 @@ _resource_created_then(void *data, void *values)
>                                      it_data,
>                                      _file_grid_cmp, NULL, NULL);
>  
> -end:
>     eo_unref(obj);
> +   return;
> +
> +cancel:
> +   eo_unref(obj);
> +   eo_unref(it_data->model);
> +   eo_unref(it_data->parent_model);
> +   eina_stringshare_add(it_data->parent_path);

Did you mean eina_stringshare_del ?

Greetings
   bu5hm4n

------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to