[gtk+/gtk-3-0] GtkThemingEngine: increase the level of the hacks



commit 98513a02a234b65d962bf771a886d435ab1946ca
Author: Ryan Lortie <desrt desrt ca>
Date:   Thu Jul 21 15:22:05 2011 +0200

    GtkThemingEngine: increase the level of the hacks
    
    GtkThemingEngine contains a rather fantastic hack that modifies-in-place
    the structure of a GParamSpec.  Recent changes to GLib have caused this
    hack to explode in a very bad way.
    
    Modify the hack to check the GLib version and do the correct thing on
    either side of the change.

 gtk/gtkthemingengine.c |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 554c96d..634a815 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -381,8 +381,28 @@ gtk_theming_engine_register_property (const gchar            *name_space,
 
   /* FIXME: hack hack hack, replacing pspec->name to include namespace */
   name = g_strdup_printf ("-%s-%s", name_space, pspec->name);
-  g_free (pspec->name);
-  pspec->name = name;
+
+  /**
+   * GParamSpec ->name field is stored in two different ways depending
+   * on the flags used to create it and the GLib verison we are using.
+   *
+   * If G_PARAM_STATIC_NAME (or G_PARAM_STATIC_STRINGS) was given then
+   * the string is interned.  It is also interned in all cases for GLib
+   * versions starting with 2.29.12.
+   *
+   * On GLib versions before 2.29.12, if G_PARAM_STATIC_NAME was not
+   * specified, then ->name was allocated with g_strdup().
+   */
+  if (glib_check_version (2, 29, 12) == NULL || (pspec->flags & G_PARAM_STATIC_NAME) != 0)
+    {
+      pspec->name = (char *) g_intern_string (name);
+      g_free (name);
+    }
+  else
+    {
+      g_free ((char *) pspec->name);
+      pspec->name = name;
+    }
 
   gtk_style_properties_register_property (parse_func, pspec);
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]