efreet - fix efreetd kill and start with clean cache case blank icons
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 11 Aug 2015 03:56:02 +0000 (12:56 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Wed, 12 Aug 2015 11:08:14 +0000 (20:08 +0900)
if you kill efreetd ANd delete all the caches, the restart of efreetd
will lose all icons until an app re-registeres icon extensions and it
can scan all icons .. and then app has to actually get the right
upodate events and do the update properly when this happens. this
fixes that scenario

@fix

src/lib/efreet/efreet_cache.c
src/lib/efreet/efreet_icon.c
src/lib/efreet/efreet_private.h

index bba77d4..88fda2e 100644 (file)
@@ -146,10 +146,63 @@ _cb_server_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
         s = efreet_language_get();
         if (s) len = strlen(s);
         ecore_ipc_server_send(ipc, 1, 0, 0, 0, 0, s, len);
+        efreet_icon_extensions_refresh();
      }
    return ECORE_CALLBACK_DONE;
 }
 
+static void
+_icon_desktop_cache_update_event_add(int event_type)
+{
+   Efreet_Event_Cache_Update *ev;
+   Efreet_Old_Cache *d = NULL;
+   Eina_List *l = NULL;
+
+   efreet_cache_desktop_close();
+
+   ev = NEW(Efreet_Event_Cache_Update, 1);
+   if (!ev) return;
+
+   IF_RELEASE(theme_name);
+
+   // Save all old caches
+   d = NEW(Efreet_Old_Cache, 1);
+   if (d)
+     {
+        d->hash = themes;
+        d->ef = icon_theme_cache;
+        l = eina_list_append(l, d);
+     }
+
+   d = NEW(Efreet_Old_Cache, 1);
+   if (d)
+     {
+        d->hash = icons;
+        d->ef = icon_cache;
+        l = eina_list_append(l, d);
+     }
+
+   d = NEW(Efreet_Old_Cache, 1);
+   if (d)
+     {
+        d->hash = fallbacks;
+        d->ef = fallback_cache;
+        l = eina_list_append(l, d);
+     }
+
+   // Create new empty caches
+   themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
+   icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
+   fallbacks = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_fallback_free));
+
+   icon_theme_cache = NULL;
+   icon_cache = NULL;
+   fallback_cache = NULL;
+
+   // Send event
+   ecore_event_add(event_type, ev, icon_cache_update_free, l);
+}
+
 static Eina_Bool
 _cb_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
 {
@@ -162,69 +215,14 @@ _cb_server_data(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
    else if (e->major == 2) // icon cache update
      {
         if (e->minor == 1)
-          {
-             Efreet_Event_Cache_Update *ev;
-
-             efreet_cache_desktop_close();
-
-             ev = NEW(Efreet_Event_Cache_Update, 1);
-             if (ev)
-                ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE, ev, NULL, NULL);
-          }
+          _icon_desktop_cache_update_event_add(EFREET_EVENT_ICON_CACHE_UPDATE);
         else
-          ecore_event_add(EFREET_EVENT_DESKTOP_CACHE_BUILD, NULL, NULL, NULL);
+          ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, NULL, NULL, NULL);
      }
    else if (e->major == 3) // desktop cache update
      {
-        Efreet_Event_Cache_Update *ev = NULL;
-        Efreet_Old_Cache *d = NULL;
-        Eina_List *l = NULL;
-
-        if (e->minor == 1)
-          {
-             ev = NEW(Efreet_Event_Cache_Update, 1);
-             if (!ev) goto error;
-
-             IF_RELEASE(theme_name);
-
-             // Save all old caches
-             d = NEW(Efreet_Old_Cache, 1);
-             if (!d) goto error;
-             d->hash = themes;
-             d->ef = icon_theme_cache;
-             l = eina_list_append(l, d);
-
-             d = NEW(Efreet_Old_Cache, 1);
-             if (!d) goto error;
-             d->hash = icons;
-             d->ef = icon_cache;
-             l = eina_list_append(l, d);
-
-             d = NEW(Efreet_Old_Cache, 1);
-             if (!d) goto error;
-             d->hash = fallbacks;
-             d->ef = fallback_cache;
-             l = eina_list_append(l, d);
-
-             // Create new empty caches
-             themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
-             icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
-             fallbacks = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_fallback_free));
-
-             icon_theme_cache = NULL;
-             icon_cache = NULL;
-             fallback_cache = NULL;
-
-             // Send event
-             ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, l);
-             goto done;
-          }
-error:
-        IF_FREE(ev);
-          EINA_LIST_FREE(l, d)
-        free(d);
+        _icon_desktop_cache_update_event_add(EFREET_EVENT_DESKTOP_CACHE_UPDATE);
      }
-done:
    return ECORE_CALLBACK_DONE;
 }
 
index 3cb7f5c..8980520 100644 (file)
@@ -62,7 +62,7 @@ efreet_icon_init(void)
         efreet_icon_extensions = eina_list_append(efreet_icon_extensions, eina_stringshare_add(default_exts[i]));
 
     efreet_extra_icon_dirs = NULL;
-    efreet_cache_icon_exts_add(efreet_icon_extensions);
+    efreet_icon_extensions_refresh();
 
     return 1;
 }
@@ -85,6 +85,12 @@ efreet_icon_shutdown(void)
     _efreet_icon_log_dom = -1;
 }
 
+void
+efreet_icon_extensions_refresh(void)
+{
+   efreet_cache_icon_exts_add(efreet_icon_extensions);
+}
+
 EAPI const char *
 efreet_icon_deprecated_user_dir_get(void)
 {
@@ -143,7 +149,7 @@ efreet_icon_extension_add(const char *ext)
     }
     else
         efreet_icon_extensions = eina_list_prepend(efreet_icon_extensions, ext);
-    efreet_cache_icon_exts_add(efreet_icon_extensions);
+    efreet_icon_extensions_refresh();
 }
 
 EAPI Eina_List **
index 9455485..139754d 100644 (file)
@@ -197,6 +197,7 @@ void efreet_cache_shutdown(void);
 
 int efreet_icon_init(void);
 void efreet_icon_shutdown(void);
+void efreet_icon_extensions_refresh(void);
 
 int efreet_menu_init(void);
 void efreet_menu_shutdown(void);