delay closing of icon theme cache

SVN revision: 55502
This commit is contained in:
Sebastian Dransfeld 2010-12-11 20:37:17 +00:00
parent d8765063db
commit 8babc062be
3 changed files with 34 additions and 23 deletions

View File

@ -90,6 +90,9 @@ static void desktop_cache_update_cache_job(void *data);
static void icon_cache_update_cache_job(void *data);
#endif
static void desktop_cache_update_free(void *data, void *ev);
#ifdef ICON_CACHE
static void icon_cache_update_free(void *data, void *ev);
#endif
EAPI int EFREET_EVENT_ICON_CACHE_UPDATE = 0;
EAPI int EFREET_EVENT_DESKTOP_CACHE_UPDATE = 0;
@ -151,7 +154,6 @@ efreet_cache_shutdown(void)
theme_name = NULL;
icon_cache = efreet_cache_close(icon_cache);
efreet_icon_themes_flush();
icon_theme_cache = efreet_cache_close(icon_theme_cache);
#endif
@ -836,6 +838,11 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
#ifdef ICON_CACHE
else if (!strcmp(file, "icon_data.update"))
{
ev = NEW(Efreet_Event_Cache_Update, 1);
if (!ev) goto error;
d = NEW(Efreet_Old_Cache, 1);
if (!d) goto error;
if (theme_cache)
{
INFO("Destorying theme cache due to cache change.");
@ -852,13 +859,14 @@ cache_update_cb(void *data __UNUSED__, Ecore_File_Monitor *em __UNUSED__,
}
icon_cache = efreet_cache_close(icon_cache);
efreet_icon_themes_flush();
/* TODO: We must delay closing this file until event is done, so users can free/refetch */
icon_theme_cache = efreet_cache_close(icon_theme_cache);
ev = NEW(Efreet_Event_Cache_Update, 1);
if (!ev) return;
ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, NULL, NULL);
d->hash = efreet_icon_themes;
d->ef = icon_theme_cache;
efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
icon_theme_cache = NULL;
ecore_event_add(EFREET_EVENT_ICON_CACHE_UPDATE, ev, icon_cache_update_free, d);
}
#endif
return;
@ -992,3 +1000,17 @@ desktop_cache_update_free(void *data, void *ev)
free(ev);
}
#ifdef ICON_CACHE
static void
icon_cache_update_free(void *data, void *ev)
{
Efreet_Old_Cache *d;
d = data;
if (d->hash)
eina_hash_free(d->hash);
efreet_cache_close(d->ef);
free(d);
free(ev);
}
#endif

View File

@ -44,9 +44,10 @@ static int _efreet_icon_log_dom = -1;
/* TODO: Scan efreet_extra_icon_dirs for themes */
Eina_Hash *efreet_icon_themes = NULL;
static const char *efreet_icon_deprecated_user_dir = NULL;
static const char *efreet_icon_user_dir = NULL;
static Eina_Hash *efreet_icon_themes = NULL;
static Eina_List *efreet_icon_extensions = NULL;
static Eina_List *efreet_extra_icon_dirs = NULL;
#ifndef ICON_CACHE
@ -352,19 +353,6 @@ efreet_icon_theme_find(const char *theme_name)
return theme;
}
#ifdef ICON_CACHE
/**
* @internal
* @brief Clears icon theme cache
*/
void
efreet_icon_themes_flush(void)
{
IF_FREE_HASH(efreet_icon_themes);
efreet_icon_themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
}
#endif
/**
* @internal
* @param icon: The icon name to strip extension

View File

@ -114,6 +114,9 @@ extern int _efreet_log_dom_global;
#define WRN(...) EINA_LOG_DOM_WARN(EFREET_MODULE_LOG_DOM, __VA_ARGS__)
extern Eina_Hash *efreet_desktop_cache;
#ifdef ICON_CACHE
extern Eina_Hash *efreet_icon_themes;
#endif
#define EFREET_DESKTOP_CACHE_MAJOR 0
#define EFREET_DESKTOP_CACHE_MINOR 1
@ -241,8 +244,6 @@ Efreet_Cache_Fallback_Icon *efreet_cache_icon_fallback_find(const char *icon);
Efreet_Icon_Theme *efreet_cache_icon_theme_find(const char *theme);
void efreet_cache_icon_theme_free(Efreet_Icon_Theme *theme);
char **efreet_cache_icon_theme_name_list(int *num);
void efreet_icon_themes_flush(void);
#endif
EAPI void efreet_hash_free(Eina_Hash *hash, Eina_Free_Cb free_cb);