mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Avoid g_type_class_peek
Most of the time, properties belong to the class we set them on. Check that first, before going into GType, which takes locks and whatnot.
This commit is contained in:
parent
d730cfcdf4
commit
19551ac983
@ -1546,16 +1546,17 @@ object_get_property (GObject *object,
|
|||||||
GParamSpec *pspec,
|
GParamSpec *pspec,
|
||||||
GValue *value)
|
GValue *value)
|
||||||
{
|
{
|
||||||
GObjectClass *class = g_type_class_peek (pspec->owner_type);
|
GTypeInstance *inst = (GTypeInstance *) object;
|
||||||
|
GObjectClass *class;
|
||||||
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
||||||
GParamSpec *redirect;
|
GParamSpec *redirect;
|
||||||
|
|
||||||
if (class == NULL)
|
if (G_LIKELY (inst->g_class->g_type == pspec->owner_type))
|
||||||
{
|
class = (GObjectClass *) inst->g_class;
|
||||||
g_warning ("'%s::%s' is not a valid property name; '%s' is not a GObject subtype",
|
else
|
||||||
g_type_name (pspec->owner_type), pspec->name, g_type_name (pspec->owner_type));
|
class = g_type_class_peek (pspec->owner_type);
|
||||||
return;
|
|
||||||
}
|
g_assert (class != NULL);
|
||||||
|
|
||||||
redirect = g_param_spec_get_redirect_target (pspec);
|
redirect = g_param_spec_get_redirect_target (pspec);
|
||||||
if (redirect)
|
if (redirect)
|
||||||
@ -1572,17 +1573,18 @@ object_set_property (GObject *object,
|
|||||||
const GValue *value,
|
const GValue *value,
|
||||||
GObjectNotifyQueue *nqueue)
|
GObjectNotifyQueue *nqueue)
|
||||||
{
|
{
|
||||||
GObjectClass *class = g_type_class_peek (pspec->owner_type);
|
GTypeInstance *inst = (GTypeInstance *) object;
|
||||||
|
GObjectClass *class;
|
||||||
GParamSpecClass *pclass;
|
GParamSpecClass *pclass;
|
||||||
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
guint param_id = PARAM_SPEC_PARAM_ID (pspec);
|
||||||
GParamSpec *redirect;
|
GParamSpec *redirect;
|
||||||
|
|
||||||
if (G_UNLIKELY (class == NULL))
|
if (G_LIKELY (inst->g_class->g_type == pspec->owner_type))
|
||||||
{
|
class = (GObjectClass *) inst->g_class;
|
||||||
g_warning ("'%s::%s' is not a valid property name; '%s' is not a GObject subtype",
|
else
|
||||||
g_type_name (pspec->owner_type), pspec->name, g_type_name (pspec->owner_type));
|
class = g_type_class_peek (pspec->owner_type);
|
||||||
return;
|
|
||||||
}
|
g_assert (class != NULL);
|
||||||
|
|
||||||
redirect = g_param_spec_get_redirect_target (pspec);
|
redirect = g_param_spec_get_redirect_target (pspec);
|
||||||
if (redirect)
|
if (redirect)
|
||||||
|
Loading…
Reference in New Issue
Block a user