mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
GParam: try to avoid further invalid uses
In an attempt to avoid some potential future abuses of the GParamSpec API, qualify the 'name' field of the structure as 'const' and add a comment noting that it is an interned string. This is a theoretical API break, but it will only ever result in warnings -- and even then, only if you were already doing something questionable. Clean up some of the warnings that were caused internally in gparam.c from these changes.
This commit is contained in:
parent
9bcb3d7457
commit
706b275116
@ -917,7 +917,7 @@ g_param_spec_pool_insert (GParamSpecPool *pool,
|
||||
GParamSpec *pspec,
|
||||
GType owner_type)
|
||||
{
|
||||
gchar *p;
|
||||
const gchar *p;
|
||||
|
||||
if (pool && pspec && owner_type > 0 && pspec->owner_type == 0)
|
||||
{
|
||||
@ -995,26 +995,31 @@ param_spec_ht_lookup (GHashTable *hash_table,
|
||||
|
||||
if (!pspec && !is_canonical (param_name))
|
||||
{
|
||||
gchar *canonical;
|
||||
|
||||
canonical = g_strdup (key.name);
|
||||
canonicalize_key (canonical);
|
||||
|
||||
/* try canonicalized form */
|
||||
key.name = g_strdup (param_name);
|
||||
key.name = canonical;
|
||||
key.owner_type = owner_type;
|
||||
|
||||
canonicalize_key (key.name);
|
||||
|
||||
if (walk_ancestors)
|
||||
do
|
||||
{
|
||||
pspec = g_hash_table_lookup (hash_table, &key);
|
||||
if (pspec)
|
||||
{
|
||||
g_free (key.name);
|
||||
return pspec;
|
||||
}
|
||||
key.owner_type = g_type_parent (key.owner_type);
|
||||
}
|
||||
while (key.owner_type);
|
||||
do
|
||||
{
|
||||
pspec = g_hash_table_lookup (hash_table, &key);
|
||||
if (pspec)
|
||||
{
|
||||
g_free (canonical);
|
||||
return pspec;
|
||||
}
|
||||
key.owner_type = g_type_parent (key.owner_type);
|
||||
}
|
||||
while (key.owner_type);
|
||||
else
|
||||
pspec = g_hash_table_lookup (hash_table, &key);
|
||||
g_free (key.name);
|
||||
pspec = g_hash_table_lookup (hash_table, &key);
|
||||
|
||||
g_free (canonical);
|
||||
}
|
||||
|
||||
return pspec;
|
||||
|
@ -205,7 +205,7 @@ struct _GParamSpec
|
||||
{
|
||||
GTypeInstance g_type_instance;
|
||||
|
||||
gchar *name;
|
||||
const gchar *name; /* interned string */
|
||||
GParamFlags flags;
|
||||
GType value_type;
|
||||
GType owner_type; /* class or interface using this property */
|
||||
|
Loading…
Reference in New Issue
Block a user