fix pspec->name assignment which needs to be strdup()ed for non
authorTim Janik <timj@gtk.org>
Thu, 22 Sep 2005 10:48:04 +0000 (10:48 +0000)
committerTim Janik <timj@src.gnome.org>
Thu, 22 Sep 2005 10:48:04 +0000 (10:48 +0000)
Thu Sep 22 12:42:12 2005  Tim Janik  <timj@gtk.org>

        * gparam.c (g_param_spec_internal): fix pspec->name assignment which
        needs to be strdup()ed for non G_PARAM_STATIC_NAME pspecs. this fixes
        recently introduced crashes during plugin unloading.
        also, ensure that static pspec names are canonicalized.

        * gsignal.h: reverted last change from matthias, we don't guarantee
        that type ids aren't mangled with G_SIGNAL_TYPE_STATIC_SCOPE anywhere.

gobject/ChangeLog
gobject/gparam.c
gobject/gsignal.h

index 659be93..60b7f8e 100644 (file)
@@ -1,3 +1,13 @@
+Thu Sep 22 12:42:12 2005  Tim Janik  <timj@gtk.org>
+
+       * gparam.c (g_param_spec_internal): fix pspec->name assignment which
+       needs to be strdup()ed for non G_PARAM_STATIC_NAME pspecs. this fixes
+       recently introduced crashes during plugin unloading.
+       also, ensure that static pspec names are canonicalized.
+
+       * gsignal.h: reverted last change from matthias, we don't guarantee
+       that type ids aren't mangled with G_SIGNAL_TYPE_STATIC_SCOPE anywhere.
+
 2005-09-20  Matthias Clasen  <mclasen@redhat.com>
 
        * gsignal.h (struct _GSignalQuery): Remove the misleading comment
index 2f983d8..454e344 100644 (file)
@@ -291,7 +291,6 @@ g_param_spec_internal (GType        param_type,
                       GParamFlags  flags)
 {
   GParamSpec *pspec;
-  gchar *tmp;
   
   g_return_val_if_fail (G_TYPE_IS_PARAM (param_type) && param_type != G_TYPE_PARAM, NULL);
   g_return_val_if_fail (name != NULL, NULL);
@@ -300,23 +299,26 @@ g_param_spec_internal (GType        param_type,
   
   pspec = (gpointer) g_type_create_instance (param_type);
 
-  if ((flags & G_PARAM_STATIC_NAME))
-    pspec->name = g_intern_static_string (name);
+  if (flags & G_PARAM_STATIC_NAME)
+    {
+      pspec->name = g_intern_static_string (name);
+      if (!is_canonical (pspec->name))
+        g_warning ("G_PARAM_STATIC_NAME used with non-canonical pspec name: %s", pspec->name);
+    }
   else
     {
-      tmp = g_strdup (name);
-      canonicalize_key (tmp);
-      pspec->name = g_intern_string (tmp);
-      g_free (tmp);
+      pspec->name = g_strdup (name);
+      canonicalize_key (pspec->name);
+      g_intern_string (pspec->name);
     }
 
   if (flags & G_PARAM_STATIC_NICK)
-    pspec->_nick = (gchar *) nick;
+    pspec->_nick = (gchar*) nick;
   else
     pspec->_nick = g_strdup (nick);
 
   if (flags & G_PARAM_STATIC_BLURB)
-    pspec->_blurb = (gchar *) blurb;
+    pspec->_blurb = (gchar*) blurb;
   else
     pspec->_blurb = g_strdup (blurb);
 
index 79e2caa..61345dc 100644 (file)
@@ -87,7 +87,7 @@ struct _GSignalQuery
   const gchar  *signal_name;
   GType                itype;
   GSignalFlags signal_flags;
-  GType                return_type; 
+  GType                return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
   guint                n_params;
   const GType  *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
 };