Fix issues with symbolic colors in rc file parsing

Don't recreate the settings color hash every time, repopulate it
instead. This avoids invalidating the references held by RcContexts.
This commit is contained in:
Matthias Clasen 2009-10-25 23:47:59 -04:00
parent 16482f20db
commit d3e6cffff7
2 changed files with 44 additions and 21 deletions

View File

@ -659,11 +659,15 @@ gtk_rc_color_hash_changed (GtkSettings *settings,
GParamSpec *pspec,
GtkRcContext *context)
{
if (context->color_hash)
g_hash_table_unref (context->color_hash);
GHashTable *old_hash;
old_hash = context->color_hash;
g_object_get (settings, "color-hash", &context->color_hash, NULL);
if (old_hash)
g_hash_table_unref (old_hash);
gtk_rc_reparse_all_for_settings (settings, TRUE);
}
@ -3148,8 +3152,10 @@ gtk_rc_parse_style (GtkRcContext *context,
break;
case GTK_RC_TOKEN_COLOR:
if (our_hash == NULL)
{
gtk_rc_style_prepend_empty_color_hash (rc_style);
our_hash = rc_priv->color_hashes->data;
}
token = gtk_rc_parse_logical_color (scanner, rc_style, our_hash);
break;
case G_TOKEN_IDENTIFIER:

View File

@ -2268,6 +2268,9 @@ update_color_hash (ColorSchemeData *data,
gboolean changed = FALSE;
gint i;
GHashTable *old_hash;
GHashTableIter iter;
gchar *name;
GdkColor *color;
if ((str == NULL || *str == '\0') &&
(data->lastentry[source] == NULL || data->lastentry[source][0] == '\0'))
@ -2301,9 +2304,23 @@ update_color_hash (ColorSchemeData *data,
return FALSE;
/* Rebuild the merged hash table. */
old_hash = data->color_hash;
data->color_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
if (data->color_hash)
{
old_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
(GDestroyNotify) gdk_color_free);
g_hash_table_iter_init (&iter, data->color_hash);
while (g_hash_table_iter_next (&iter, &name, &color))
{
g_hash_table_insert (old_hash, name, color);
g_hash_table_iter_steal (&iter);
}
}
else
{
old_hash = NULL;
}
for (i = 0; i <= GTK_SETTINGS_SOURCE_APPLICATION; i++)
{
if (data->tables[i])