gstobject: Don't double-notify when setting names

If the name is set via the gobject setters, the notificatio will
already be emitted.
This commit is contained in:
Edward Hervey 2020-04-17 07:44:26 +02:00 committed by Edward Hervey
parent dd2ec3681e
commit d4f84ad4e6

View file

@ -595,6 +595,38 @@ had_parent:
} }
} }
static gboolean
gst_object_set_name_intern (GstObject * object, const gchar * name)
{
gboolean result;
GST_OBJECT_LOCK (object);
/* parented objects cannot be renamed */
if (G_UNLIKELY (object->parent != NULL))
goto had_parent;
if (name != NULL) {
g_free (object->name);
object->name = g_strdup (name);
GST_OBJECT_UNLOCK (object);
result = TRUE;
} else {
GST_OBJECT_UNLOCK (object);
result = gst_object_set_name_default (object);
}
return result;
/* error */
had_parent:
{
GST_WARNING ("parented objects can't be renamed");
GST_OBJECT_UNLOCK (object);
return FALSE;
}
}
/** /**
* gst_object_set_name: * gst_object_set_name:
* @object: a #GstObject * @object: a #GstObject
@ -618,32 +650,9 @@ gst_object_set_name (GstObject * object, const gchar * name)
g_return_val_if_fail (GST_IS_OBJECT (object), FALSE); g_return_val_if_fail (GST_IS_OBJECT (object), FALSE);
GST_OBJECT_LOCK (object); if ((result = gst_object_set_name_intern (object, name)))
g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_NAME]);
/* parented objects cannot be renamed */
if (G_UNLIKELY (object->parent != NULL))
goto had_parent;
if (name != NULL) {
g_free (object->name);
object->name = g_strdup (name);
GST_OBJECT_UNLOCK (object);
result = TRUE;
} else {
GST_OBJECT_UNLOCK (object);
result = gst_object_set_name_default (object);
}
g_object_notify_by_pspec (G_OBJECT (object), properties[PROP_NAME]);
return result; return result;
/* error */
had_parent:
{
GST_WARNING ("parented objects can't be renamed");
GST_OBJECT_UNLOCK (object);
return FALSE;
}
} }
/** /**
@ -926,7 +935,7 @@ gst_object_set_property (GObject * object, guint prop_id,
switch (prop_id) { switch (prop_id) {
case PROP_NAME: case PROP_NAME:
gst_object_set_name (gstobject, g_value_get_string (value)); gst_object_set_name_intern (gstobject, g_value_get_string (value));
break; break;
case PROP_PARENT: case PROP_PARENT:
gst_object_set_parent (gstobject, g_value_get_object (value)); gst_object_set_parent (gstobject, g_value_get_object (value));