From b4bdf5193554191f6f672922f1cbe249738a77ba Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 8 Feb 2019 17:48:26 -0300 Subject: [PATCH] layer: factor out a method to remove an object without signaling it --- ges/ges-layer.c | 51 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/ges/ges-layer.c b/ges/ges-layer.c index b04a2f9f75..204efaccfc 100644 --- a/ges/ges-layer.c +++ b/ges/ges-layer.c @@ -379,28 +379,12 @@ ges_layer_get_duration (GESLayer * layer) return duration; } -/* Public methods */ -/** - * ges_layer_remove_clip: - * @layer: a #GESLayer - * @clip: the #GESClip to remove - * - * Removes the given @clip from the @layer and unparents it. - * Unparenting it means the reference owned by @layer on the @clip will be - * removed. If you wish to use the @clip after this function, make sure you - * call gst_object_ref() before removing it from the @layer. - * - * Returns: %TRUE if the clip could be removed, %FALSE if the layer does - * not want to remove the clip. - */ -gboolean -ges_layer_remove_clip (GESLayer * layer, GESClip * clip) +static gboolean +ges_layer_remove_clip_internal (GESLayer * layer, GESClip * clip, + gboolean emit_removed) { GESLayer *current_layer; - g_return_val_if_fail (GES_IS_LAYER (layer), FALSE); - g_return_val_if_fail (GES_IS_CLIP (clip), FALSE); - GST_DEBUG ("layer:%p, clip:%p", layer, clip); current_layer = ges_clip_get_layer (clip); @@ -417,8 +401,10 @@ ges_layer_remove_clip (GESLayer * layer, GESClip * clip) /* Remove it from our list of controlled objects */ layer->priv->clips_start = g_list_remove (layer->priv->clips_start, clip); - /* emit 'clip-removed' */ - g_signal_emit (layer, ges_layer_signals[OBJECT_REMOVED], 0, clip); + if (emit_removed) { + /* emit 'clip-removed' */ + g_signal_emit (layer, ges_layer_signals[OBJECT_REMOVED], 0, clip); + } /* inform the clip it's no longer in a layer */ ges_clip_set_layer (clip, NULL); @@ -432,6 +418,29 @@ ges_layer_remove_clip (GESLayer * layer, GESClip * clip) return TRUE; } +/* Public methods */ +/** + * ges_layer_remove_clip: + * @layer: a #GESLayer + * @clip: the #GESClip to remove + * + * Removes the given @clip from the @layer and unparents it. + * Unparenting it means the reference owned by @layer on the @clip will be + * removed. If you wish to use the @clip after this function, make sure you + * call gst_object_ref() before removing it from the @layer. + * + * Returns: %TRUE if the clip could be removed, %FALSE if the layer does + * not want to remove the clip. + */ +gboolean +ges_layer_remove_clip (GESLayer * layer, GESClip * clip) +{ + g_return_val_if_fail (GES_IS_LAYER (layer), FALSE); + g_return_val_if_fail (GES_IS_CLIP (clip), FALSE); + + return ges_layer_remove_clip_internal (layer, clip, TRUE); +} + /** * ges_layer_set_priority: * @layer: a #GESLayer