raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=6540eddb9671b22bbe73bf2117c25deb69a87a5b

commit 6540eddb9671b22bbe73bf2117c25deb69a87a5b
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu Dec 15 16:31:56 2016 +0900

    e module - remove duplicate modules at load all time from config
    
    ALSO dont remove dups from e_module_new as we may be walking at the
    time. instead refuse to load a module alread loaded bu name. this
    should solve things better.
    
    @fix
---
 src/bin/e_module.c | 51 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/src/bin/e_module.c b/src/bin/e_module.c
index 9bfc317..3cb794c 100644
--- a/src/bin/e_module.c
+++ b/src/bin/e_module.c
@@ -13,6 +13,7 @@ static void      _e_module_dialog_disable_create(const char 
*title, const char *
 static void      _e_module_cb_dialog_disable(void *data, E_Dialog *dia);
 static void      _e_module_event_update_free(void *data, void *event);
 static Eina_Bool _e_module_cb_idler(void *data);
+static int       _e_module_sort_name(const void *d1, const void *d2);
 static int       _e_module_sort_priority(const void *d1, const void *d2);
 static void      _e_module_whitelist_check(void);
 static Eina_Bool _e_module_desktop_list_cb(const Eina_Hash *hash EINA_UNUSED, 
const void *key, void *data, void *fdata);
@@ -264,12 +265,28 @@ E_API void
 e_module_all_load(void)
 {
    Eina_List *l, *ll;
-   E_Config_Module *em;
+   E_Config_Module *em, *em2;
    char buf[128];
 
    _e_modules_initting = EINA_TRUE;
    if (_e_module_path_lists) return;
 
+   // remove duplicate modules in load
+   e_config->modules =
+     eina_list_sort(e_config->modules, 0, _e_module_sort_name);
+   EINA_LIST_FOREACH_SAFE(e_config->modules, l, ll, em)
+     {
+        if ((!em) || (!ll)) continue;
+        em2 = ll->data;
+        if (!em2) continue;
+
+        if (!strcmp(em->name, em2->name))
+          {
+             eina_stringshare_del(em->name);
+             e_config->modules = eina_list_remove_list(e_config->modules, l);
+             free(em);
+          }
+     }
    e_config->modules =
      eina_list_sort(e_config->modules, 0, _e_module_sort_priority);
 
@@ -332,11 +349,11 @@ e_module_new(const char *name)
    char body[4096], title[1024];
    const char *modpath = NULL;
    char *s;
-   Eina_List *l, *ll;
-   E_Config_Module *em;
    int in_list = 0;
 
    if (!name) return NULL;
+   if (eina_hash_find(_e_modules_hash, name)) return NULL;
+
    m = E_OBJECT_ALLOC(E_Module, E_MODULE_TYPE, _e_module_free);
    if (name[0] != '/')
      {
@@ -461,22 +478,6 @@ init_done:
                }
           }
      }
-   EINA_LIST_FOREACH_SAFE(e_config->modules, l, ll, em)
-     {
-        if (!em) continue;
-        if (em->name == m->name)
-          {
-             if (in_list)
-               {
-                  /* duplicate module config */
-                  e_config->modules = eina_list_remove_list(e_config->modules, 
l);
-                  eina_stringshare_del(em->name);
-                  free(em);
-               }
-             else
-               in_list = 1;
-          }
-     }
    if (!in_list)
      {
         E_Config_Module *module;
@@ -891,6 +892,18 @@ _e_module_cb_idler(void *data EINA_UNUSED)
 }
 
 static int
+_e_module_sort_name(const void *d1, const void *d2)
+{
+   const E_Config_Module *m1, *m2;
+
+   m1 = d1;
+   if (!m1->name) return -1;
+   m2 = d2;
+   if (!m2->name) return 1;
+   return strcmp(m1->name, m2->name);
+}
+
+static int
 _e_module_sort_priority(const void *d1, const void *d2)
 {
    const E_Config_Module *m1, *m2;

-- 


Reply via email to