fix pspec->name assignment which needs to be strdup()ed for non

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.
This commit is contained in:
Tim Janik 2005-09-22 10:48:04 +00:00 committed by Tim Janik
parent a07b4b8c02
commit b94a2fe66c
3 changed files with 22 additions and 10 deletions

View 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> 2005-09-20 Matthias Clasen <mclasen@redhat.com>
* gsignal.h (struct _GSignalQuery): Remove the misleading comment * gsignal.h (struct _GSignalQuery): Remove the misleading comment

View File

@ -291,7 +291,6 @@ g_param_spec_internal (GType param_type,
GParamFlags flags) GParamFlags flags)
{ {
GParamSpec *pspec; 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 (G_TYPE_IS_PARAM (param_type) && param_type != G_TYPE_PARAM, NULL);
g_return_val_if_fail (name != NULL, 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); pspec = (gpointer) g_type_create_instance (param_type);
if ((flags & G_PARAM_STATIC_NAME)) if (flags & G_PARAM_STATIC_NAME)
pspec->name = g_intern_static_string (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 else
{ {
tmp = g_strdup (name); pspec->name = g_strdup (name);
canonicalize_key (tmp); canonicalize_key (pspec->name);
pspec->name = g_intern_string (tmp); g_intern_string (pspec->name);
g_free (tmp);
} }
if (flags & G_PARAM_STATIC_NICK) if (flags & G_PARAM_STATIC_NICK)
pspec->_nick = (gchar *) nick; pspec->_nick = (gchar*) nick;
else else
pspec->_nick = g_strdup (nick); pspec->_nick = g_strdup (nick);
if (flags & G_PARAM_STATIC_BLURB) if (flags & G_PARAM_STATIC_BLURB)
pspec->_blurb = (gchar *) blurb; pspec->_blurb = (gchar*) blurb;
else else
pspec->_blurb = g_strdup (blurb); pspec->_blurb = g_strdup (blurb);

View File

@ -87,7 +87,7 @@ struct _GSignalQuery
const gchar *signal_name; const gchar *signal_name;
GType itype; GType itype;
GSignalFlags signal_flags; GSignalFlags signal_flags;
GType return_type; GType return_type; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
guint n_params; guint n_params;
const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */ const GType *param_types; /* mangled with G_SIGNAL_TYPE_STATIC_SCOPE flag */
}; };