gtk2/gtk2-303869-disable-icon-cache-validation.diff

115 lines
3.9 KiB
Diff
Raw Normal View History

2007-09-12 Federico Mena Quintero <federico@novell.com>
Fix the critical part of
https://bugzilla.novell.com/show_bug.cgi?id=303869
http://bugzilla.gnome.org/show_bug.cgi?id=476342
* gtk/gtkiconcachevalidator.c (_gtk_icon_cache_validate): To avoid
massive page-in when starting an application, don't validate icon
caches unless we have "GTK_DEBUG=icontheme".
* gtk/gtkiconcache.c (_gtk_icon_cache_new_for_path): Tell
_gtk_icon_cache_validate() that it is not mandatory to do the
validation.
* gtk/updateiconcache.c (validate_file): Here it *is* mandatory to
do the validation.
Index: gtk+-2.12.1/gtk/gtkiconcache.c
===================================================================
--- gtk+-2.12.1.orig/gtk/gtkiconcache.c
+++ gtk+-2.12.1/gtk/gtkiconcache.c
@@ -130,7 +130,7 @@ _gtk_icon_cache_new_for_path (const gcha
#ifdef G_ENABLE_DEBUG
if (gtk_debug_flags & GTK_DEBUG_ICONTHEME)
{
- if (!_gtk_icon_cache_validate (&info))
+ if (!_gtk_icon_cache_validate (&info, path, FALSE))
{
g_mapped_file_free (map);
g_warning ("Icon cache '%s' is invalid\n", cache_filename);
Index: gtk+-2.12.1/gtk/gtkiconcachevalidator.c
===================================================================
--- gtk+-2.12.1.orig/gtk/gtkiconcachevalidator.c
+++ gtk+-2.12.1/gtk/gtkiconcachevalidator.c
@@ -17,6 +17,7 @@
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
+#include "gtkdebug.h"
#include "gtkiconcachevalidator.h"
#include <glib.h>
@@ -370,7 +371,10 @@ check_hash (CacheInfo *info,
/**
* _gtk_icon_cache_validate:
- * @info: a CacheInfo structure
+ * @info: a CacheInfo structure
+ * @icon_path: Name of the file that is being checked (unused except for debug output)
+ * @mandatory: Whether to actually perform the validation; if FALSE, validation will only
+ * be performed if there is an environment variable GTK_DEBUG=icontheme.
*
* Validates the icon cache passed in the @cache and
* @cache_size fields of the @info structure. The
@@ -383,11 +387,19 @@ check_hash (CacheInfo *info,
* Return value: %TRUE if the cache is valid
*/
gboolean
-_gtk_icon_cache_validate (CacheInfo *info)
+_gtk_icon_cache_validate (CacheInfo *info,
+ const gchar *icon_path,
+ gboolean mandatory)
{
guint32 hash_offset;
guint32 directory_list_offset;
+ if (!mandatory && (gtk_debug_flags & GTK_DEBUG_ICONTHEME) == 0)
+ return TRUE;
+
+ GTK_NOTE (ICONTHEME,
+ g_print ("validating icon cache for %s", icon_path));
+
if (!check_version (info))
return FALSE;
check ("header, hash offset", get_uint32 (info, 4, &hash_offset));
Index: gtk+-2.12.1/gtk/gtkiconcachevalidator.h
===================================================================
--- gtk+-2.12.1.orig/gtk/gtkiconcachevalidator.h
+++ gtk+-2.12.1/gtk/gtkiconcachevalidator.h
@@ -37,7 +37,9 @@ typedef struct {
gint flags;
} CacheInfo;
-gboolean _gtk_icon_cache_validate (CacheInfo *info);
+gboolean _gtk_icon_cache_validate (CacheInfo *info,
+ const gchar *icon_path,
+ gboolean mandatory);
G_END_DECLS
Index: gtk+-2.12.1/gtk/updateiconcache.c
===================================================================
--- gtk+-2.12.1.orig/gtk/updateiconcache.c
+++ gtk+-2.12.1/gtk/updateiconcache.c
@@ -49,6 +49,10 @@ static gboolean validate = FALSE;
static gchar *var_name = "-";
static gboolean remove_empty_cache = FALSE;
+guint gtk_debug_flags; /* HACK: gtkiconcachevalidator.c needs this from
+ * gtkdebug.h/gtkmain.c, but we don't link to libgtk.
+ */
+
/* Quite ugly - if we just add the c file to the
* list of sources in Makefile.am, libtool complains.
*/
@@ -1408,7 +1412,7 @@ validate_file (const gchar *file)
info.n_directories = 0;
info.flags = CHECK_OFFSETS|CHECK_STRINGS|CHECK_PIXBUFS;
- if (!_gtk_icon_cache_validate (&info))
+ if (!_gtk_icon_cache_validate (&info, file, TRUE))
{
g_mapped_file_free (map);
return FALSE;