From d420730347e65a2618e0889ed6fd6417325b1522 Mon Sep 17 00:00:00 2001 From: Jens Granseuer Date: Wed, 24 Oct 2007 21:18:10 +0000 Subject: [PATCH] This change hopefully fixes bug #484797 which I suspect is caused by the 2007-10-24 Jens Granseuer This change hopefully fixes bug #484797 which I suspect is caused by the capplet getting stale data from from the themes module which in turn is caused by deleted themes being freed but not removed from the hash cache. * gnome-theme-info.c: (update_common_theme_dir_index): actually remove theme data from the hash when the theme gets deleted; also don't unconditionally cast to icon theme svn path=/trunk/; revision=8194 --- capplets/common/ChangeLog | 11 +++++++++++ capplets/common/gnome-theme-info.c | 17 +++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index 33fbd398f..3fb8cee28 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,14 @@ +2007-10-24 Jens Granseuer + + This change hopefully fixes bug #484797 which I suspect is caused by + the capplet getting stale data from from the themes module which in + turn is caused by deleted themes being freed but not removed from the + hash cache. + + * gnome-theme-info.c: (update_common_theme_dir_index): actually remove + theme data from the hash when the theme gets deleted; also don't + unconditionally cast to icon theme + 2007-10-14 Jens Granseuer * gnome-theme-info.c: (gnome_theme_init): fix invalid use after free I diff --git a/capplets/common/gnome-theme-info.c b/capplets/common/gnome-theme-info.c index 44e71cd27..68afb0fec 100644 --- a/capplets/common/gnome-theme-info.c +++ b/capplets/common/gnome-theme-info.c @@ -588,7 +588,7 @@ update_common_theme_dir_index (GnomeVFSURI *theme_index_uri, gchar *common_theme_dir; GHashTable *hash_by_uri; GHashTable *hash_by_name; - gchar *name = NULL; + const gchar *name = NULL; if (icon_theme) { @@ -653,6 +653,7 @@ update_common_theme_dir_index (GnomeVFSURI *theme_index_uri, else name = ((GnomeThemeMetaInfo *)theme_info)->name; } + if (old_theme_info == NULL) { if (theme_exists) @@ -665,6 +666,12 @@ update_common_theme_dir_index (GnomeVFSURI *theme_index_uri, } else { + const gchar *old_name; + if (icon_theme) + old_name = ((GnomeThemeIconInfo *)old_theme_info)->name; + else + old_name = ((GnomeThemeMetaInfo *)old_theme_info)->name; + if (theme_exists) { gint cmp; @@ -678,7 +685,7 @@ update_common_theme_dir_index (GnomeVFSURI *theme_index_uri, { /* Remove old theme */ g_hash_table_remove (hash_by_uri, common_theme_dir); - remove_data_from_hash_by_name (hash_by_name, ((GnomeThemeIconInfo *)old_theme_info)->name, old_theme_info); + remove_data_from_hash_by_name (hash_by_name, old_name, old_theme_info); g_hash_table_insert (hash_by_uri, g_strdup (common_theme_dir), theme_info); add_data_to_hash_by_name (hash_by_name, name, theme_info); handle_change_signal (icon_theme?GNOME_THEME_TYPE_ICON:GNOME_THEME_TYPE_METATHEME, @@ -698,10 +705,8 @@ update_common_theme_dir_index (GnomeVFSURI *theme_index_uri, } else { - if (icon_theme) - name = ((GnomeThemeIconInfo *)old_theme_info)->name; - else - name = ((GnomeThemeMetaInfo *)old_theme_info)->name; + g_hash_table_remove (hash_by_uri, common_theme_dir); + remove_data_from_hash_by_name (hash_by_name, old_name, old_theme_info); handle_change_signal (icon_theme?GNOME_THEME_TYPE_ICON:GNOME_THEME_TYPE_METATHEME, old_theme_info, GNOME_THEME_CHANGE_DELETED, 0);