Commit 0767f08c authored by Thibault Saunier's avatar Thibault Saunier
Browse files

Always prefer gst_object_(un)ref over g_object_(un)ref

Making the refcount issue debugging easier
parent dd504277
......@@ -509,7 +509,7 @@ ges_asset_cache_set_loaded (GType extractable_type, const gchar * id,
g_list_foreach (entry->results,
(GFunc) g_simple_async_result_complete_in_idle, NULL);
g_list_free_full (entry->results, g_object_unref);
g_list_free_full (entry->results, gst_object_unref);
entry->results = NULL;
UNLOCK_CACHE;
}
......@@ -820,7 +820,7 @@ done:
* ges_asset_get_id (source), error->message);
* }
*
* g_object_unref (mfs);
* gst_object_unref (mfs);
* }
*
* // The request:
......@@ -982,7 +982,7 @@ ges_asset_request_finish (GAsyncResult * res, GError ** error)
object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object),
res, error);
g_object_unref (source_object);
gst_object_unref (source_object);
return GES_ASSET (object);
}
......
......@@ -152,7 +152,7 @@ done:
g_free (xmlcontent);
if (file)
g_object_unref (file);
gst_object_unref (file);
return parsecontext;
......@@ -197,7 +197,7 @@ _can_load_uri (GESFormatterClass * class, const gchar * uri, GError ** error)
g_markup_parse_context_free (ctx);
done:
g_object_unref (self);
gst_object_unref (self);
return ret;
}
......@@ -257,8 +257,8 @@ _save_to_uri (GESFormatter * formatter, GESTimeline * timeline,
lerror->message);
g_string_free (str, TRUE);
g_object_unref (file);
g_object_unref (stream);
gst_object_unref (file);
gst_object_unref (stream);
if (lerror)
g_propagate_error (error, lerror);
......@@ -266,17 +266,17 @@ _save_to_uri (GESFormatter * formatter, GESTimeline * timeline,
return ret;
serialization_failed:
g_object_unref (file);
gst_object_unref (file);
g_output_stream_close (stream, NULL, NULL);
g_object_unref (stream);
gst_object_unref (stream);
if (lerror)
g_propagate_error (error, lerror);
return FALSE;
failed_opening_file:
g_object_unref (file);
gst_object_unref (file);
GST_WARNING_OBJECT (formatter, "Could not open %s because: %s", uri,
lerror->message);
......@@ -396,7 +396,7 @@ _set_child_property (GQuark field_id, const GValue * value,
g_object_set_property (G_OBJECT (element), pspec->name, value);
g_param_spec_unref (pspec);
g_object_unref (element);
gst_object_unref (element);
}
void
......
......@@ -167,7 +167,7 @@ _remove_child (GESContainer * container, GESTimelineElement * element)
static void
add_tlobj_to_list (gpointer key, gpointer tlobj, GList ** list)
{
*list = g_list_prepend (*list, g_object_ref (tlobj));
*list = g_list_prepend (*list, gst_object_ref (tlobj));
}
static GList *
......@@ -710,18 +710,18 @@ ges_clip_move_to_layer (GESClip * clip, GESTimelineLayer * layer)
ges_timeline_layer_get_priority (layer));
clip->priv->is_moving = TRUE;
g_object_ref (clip);
gst_object_ref (clip);
ret = ges_timeline_layer_remove_clip (current_layer, clip);
if (!ret) {
g_object_unref (clip);
gst_object_unref (clip);
return FALSE;
}
ret = ges_timeline_layer_add_clip (layer, clip);
clip->priv->is_moving = FALSE;
g_object_unref (clip);
gst_object_unref (clip);
return ret;
}
......@@ -762,7 +762,7 @@ ges_clip_find_track_element (GESClip * clip, GESTrack * track, GType type)
continue;
ret = GES_TRACK_ELEMENT (tmp->data);
g_object_ref (ret);
gst_object_ref (ret);
break;
}
}
......@@ -786,7 +786,7 @@ ges_clip_get_layer (GESClip * clip)
g_return_val_if_fail (GES_IS_CLIP (clip), NULL);
if (clip->priv->layer != NULL)
g_object_ref (G_OBJECT (clip->priv->layer));
gst_object_ref (G_OBJECT (clip->priv->layer));
return clip->priv->layer;
}
......@@ -817,7 +817,7 @@ ges_clip_get_top_effects (GESClip * clip)
for (tmp = GES_CONTAINER_CHILDREN (clip), i = 0;
i < clip->priv->nb_effects; tmp = tmp->next, i++) {
ret = g_list_append (ret, g_object_ref (tmp->data));
ret = g_list_append (ret, gst_object_ref (tmp->data));
}
return g_list_sort (ret, (GCompareFunc) element_start_compare);
......
......@@ -136,7 +136,7 @@ _free_mapping (ChildMapping * mapping)
g_signal_handler_disconnect (child, mapping->priority_notifyid);
ges_timeline_element_set_parent (child, NULL);
g_object_unref (child);
gst_object_unref (child);
g_slice_free (ChildMapping, mapping);
}
......@@ -568,7 +568,7 @@ ges_container_add (GESContainer * container, GESTimelineElement * child)
priv->ignore_notifies = FALSE;
mapping = g_slice_new0 (ChildMapping);
mapping->child = g_object_ref (child);
mapping->child = gst_object_ref (child);
mapping->start_offset = _START (container) - _START (child);
mapping->duration_offset = _DURATION (container) - _DURATION (child);
mapping->inpoint_offset = _INPOINT (container) - _INPOINT (child);
......
......@@ -96,7 +96,7 @@ static void
free_src_map (SrcMapping * srcmap)
{
g_free (srcmap->id);
g_object_unref (srcmap->clip);
gst_object_unref (srcmap->clip);
g_list_foreach (srcmap->track_element_ids, (GFunc) g_free, NULL);
g_list_free (srcmap->track_element_ids);
g_slice_free (SrcMapping, srcmap);
......@@ -332,7 +332,7 @@ save_tracks (GESTimeline * timeline, xmlTextWriterPtr writer,
xmlTextWriterEndElement (writer);
}
g_list_foreach (tracks, (GFunc) g_object_unref, NULL);
g_list_foreach (tracks, (GFunc) gst_object_unref, NULL);
g_list_free (tracks);
xmlTextWriterEndElement (writer);
}
......@@ -388,15 +388,15 @@ save_sources (GESPitiviFormatter * formatter, GList * layers,
srcmap->id =
g_strdup (g_hash_table_lookup (priv->saving_source_table,
uriclip_uri));
srcmap->clip = g_object_ref (clip);
srcmap->clip = gst_object_ref (clip);
srcmap->priority = ges_timeline_layer_get_priority (layer);
/* We fill up the track_element_ids in save_track_elements */
source_list = g_list_append (source_list, srcmap);
}
}
g_list_foreach (clips, (GFunc) g_object_unref, NULL);
g_list_foreach (clips, (GFunc) gst_object_unref, NULL);
g_list_free (clips);
g_object_unref (G_OBJECT (layer));
gst_object_unref (G_OBJECT (layer));
}
return source_list;
......@@ -516,7 +516,7 @@ create_tracks (GESFormatter * self)
priv->trackv = track;
}
}
g_list_foreach (tracks, (GFunc) g_object_unref, NULL);
g_list_foreach (tracks, (GFunc) gst_object_unref, NULL);
g_list_free (tracks);
return TRUE;
}
......@@ -1147,7 +1147,7 @@ ges_pitivi_formatter_init (GESPitiviFormatter * self)
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
priv->layers_table =
g_hash_table_new_full (g_int_hash, g_str_equal, g_free, g_object_unref);
g_hash_table_new_full (g_int_hash, g_str_equal, g_free, gst_object_unref);
priv->sources_table =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
......
......@@ -674,7 +674,7 @@ ges_project_list_assets (GESProject * project, GType filter)
while (g_hash_table_iter_next (&iter, &key, &value)) {
if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
filter))
ret = g_list_append (ret, g_object_ref (value));
ret = g_list_append (ret, gst_object_ref (value));
}
return ret;
......
......@@ -419,11 +419,11 @@ ges_simple_timeline_layer_move_object (GESSimpleTimelineLayer * layer,
if (G_UNLIKELY (clip_layer != (GESTimelineLayer *) layer)) {
GST_WARNING ("Clip doesn't belong to this layer");
if (clip_layer != NULL)
g_object_unref (clip_layer);
gst_object_unref (clip_layer);
return FALSE;
}
if (clip_layer != NULL)
g_object_unref (clip_layer);
gst_object_unref (clip_layer);
/* Find it's current position */
idx = g_list_index (priv->objects, clip);
......@@ -526,7 +526,7 @@ get_objects (GESTimelineLayer * l)
ret = g_list_copy (layer->priv->objects);
for (tmp = ret; tmp; tmp = tmp->next) {
g_object_ref (tmp->data);
gst_object_ref (tmp->data);
}
return ret;
......
......@@ -367,7 +367,7 @@ ges_test_clip_new (void)
GESAsset *asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
new_clip = GES_TEST_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
gst_object_unref (asset);
return new_clip;
}
......
......@@ -606,7 +606,7 @@ ges_text_overlay_clip_new (void)
GESAsset *asset = ges_asset_request (GES_TYPE_OVERLAY_TEXT_CLIP, NULL, NULL);
new_clip = GES_OVERLAY_TEXT_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
gst_object_unref (asset);
return new_clip;
}
......@@ -106,7 +106,7 @@ ges_text_overlay_dispose (GObject * object)
}
if (self->priv->text_el) {
g_object_unref (self->priv->text_el);
gst_object_unref (self->priv->text_el);
self->priv->text_el = NULL;
}
......@@ -151,7 +151,7 @@ ges_text_overlay_create_element (GESTrackElement * track_element)
iconv = gst_element_factory_make ("videoconvert", NULL);
oconv = gst_element_factory_make ("videoconvert", NULL);
self->priv->text_el = text;
g_object_ref (text);
gst_object_ref (text);
if (self->priv->text)
g_object_set (text, "text", (gchar *) self->priv->text, NULL);
......@@ -173,8 +173,8 @@ ges_text_overlay_create_element (GESTrackElement * track_element)
src = gst_ghost_pad_new ("src", src_target);
sink = gst_ghost_pad_new ("video_sink", sink_target);
g_object_unref (src_target);
g_object_unref (sink_target);
gst_object_unref (src_target);
gst_object_unref (sink_target);
gst_element_add_pad (ret, src);
gst_element_add_pad (ret, sink);
......
......@@ -271,7 +271,7 @@ new_asset_cb (GESAsset * source, GAsyncResult * res, NewAssetUData * udata)
ges_timeline_layer_add_clip (udata->layer, udata->clip);
}
g_object_unref (asset);
gst_object_unref (asset);
g_slice_free (NewAssetUData, udata);
}
......@@ -284,7 +284,7 @@ new_asset_cb (GESAsset * source, GAsyncResult * res, NewAssetUData * udata)
* 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 g_object_ref() before removing it from the @layer.
* 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.
......@@ -304,11 +304,11 @@ ges_timeline_layer_remove_clip (GESTimelineLayer * layer, GESClip * clip)
GST_WARNING ("Clip doesn't belong to this layer");
if (current_layer != NULL)
g_object_unref (current_layer);
gst_object_unref (current_layer);
return FALSE;
}
g_object_unref (current_layer);
gst_object_unref (current_layer);
/* emit 'clip-removed' */
g_signal_emit (layer, ges_timeline_layer_signals[OBJECT_REMOVED], 0, clip);
......@@ -322,7 +322,7 @@ ges_timeline_layer_remove_clip (GESTimelineLayer * layer, GESClip * clip)
layer->priv->clips_start = g_list_remove (layer->priv->clips_start, clip);
/* Remove our reference to the clip */
g_object_unref (clip);
gst_object_unref (clip);
return TRUE;
}
......@@ -485,7 +485,7 @@ ges_timeline_layer_add_clip (GESTimelineLayer * layer, GESClip * clip)
current_layer = ges_clip_get_layer (clip);
if (G_UNLIKELY (current_layer)) {
GST_WARNING ("Clip %p already belongs to another layer", clip);
g_object_unref (current_layer);
gst_object_unref (current_layer);
return FALSE;
}
......
......@@ -346,7 +346,7 @@ ges_timeline_pipeline_update_caps (GESTimelinePipeline * self)
}
}
g_object_unref (track);
gst_object_unref (track);
}
if (tracks)
......@@ -796,7 +796,7 @@ ges_timeline_pipeline_set_render_settings (GESTimelinePipeline * pipeline,
/* FIXME : We should figure out if it was added to the pipeline,
* and if so, remove it. */
if (pipeline->priv->urisink) {
g_object_unref (pipeline->priv->urisink);
gst_object_unref (pipeline->priv->urisink);
pipeline->priv->urisink = NULL;
}
......@@ -858,7 +858,7 @@ ges_timeline_pipeline_set_mode (GESTimelinePipeline * pipeline,
!(mode & TIMELINE_MODE_PREVIEW)) {
/* Disable playsink */
GST_DEBUG ("Disabling playsink");
g_object_ref (pipeline->priv->playsink);
gst_object_ref (pipeline->priv->playsink);
gst_bin_remove (GST_BIN_CAST (pipeline), pipeline->priv->playsink);
}
if ((pipeline->priv->mode &
......@@ -883,8 +883,8 @@ ges_timeline_pipeline_set_mode (GESTimelinePipeline * pipeline,
/* Disable render bin */
GST_DEBUG ("Disabling rendering bin");
g_object_ref (pipeline->priv->encodebin);
g_object_ref (pipeline->priv->urisink);
gst_object_ref (pipeline->priv->encodebin);
gst_object_ref (pipeline->priv->urisink);
gst_bin_remove_many (GST_BIN_CAST (pipeline),
pipeline->priv->encodebin, pipeline->priv->urisink, NULL);
}
......
......@@ -527,7 +527,7 @@ ges_timeline_init (GESTimeline * self)
priv->obj_iters = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
(GDestroyNotify) _destroy_obj_iters);
priv->starts_ends = g_sequence_new (g_free);
priv->tracksources = g_sequence_new (g_object_unref);
priv->tracksources = g_sequence_new (gst_object_unref);
priv->auto_transitions =
g_hash_table_new_full (g_str_hash, g_str_equal, NULL, gst_object_unref);
......@@ -978,7 +978,7 @@ start_tracking_track_element (GESTimeline * timeline,
(GCompareDataFunc) compare_uint64, NULL);
iters->iter_obj =
g_sequence_insert_sorted (priv->tracksources,
g_object_ref (trackelement), (GCompareDataFunc) element_start_compare,
gst_object_ref (trackelement), (GCompareDataFunc) element_start_compare,
NULL);
iters->trackelement = trackelement;
......@@ -1153,7 +1153,7 @@ add_moving_clip (MoveContext * mv_ctx, GESTrackElement * trackelement)
mv_ctx->min_move_layer = MIN (mv_ctx->min_move_layer, layer_prio);
mv_ctx->max_layer_prio = MAX (mv_ctx->max_layer_prio, layer_prio);
g_object_unref (layer);
gst_object_unref (layer);
}
}
......@@ -1733,7 +1733,7 @@ timeline_context_to_layer (GESTimeline * timeline, gint offset)
ret &= ges_clip_move_to_layer (key, new_layer);
g_object_unref (layer);
gst_object_unref (layer);
}
/* Readjust min_move_layer */
......@@ -2355,7 +2355,7 @@ ges_timeline_add_layer (GESTimeline * timeline, GESTimelineLayer * layer)
objects = ges_timeline_layer_get_clips (layer);
for (tmp = objects; tmp; tmp = tmp->next) {
layer_object_added_cb (layer, tmp->data, timeline);
g_object_unref (tmp->data);
gst_object_unref (tmp->data);
tmp->data = NULL;
}
g_list_free (objects);
......@@ -2392,7 +2392,7 @@ ges_timeline_remove_layer (GESTimeline * timeline, GESTimelineLayer * layer)
layer_objects = ges_timeline_layer_get_clips (layer);
for (tmp = layer_objects; tmp; tmp = tmp->next) {
layer_object_removed_cb (layer, GES_CLIP (tmp->data), timeline);
g_object_unref (G_OBJECT (tmp->data));
gst_object_unref (G_OBJECT (tmp->data));
tmp->data = NULL;
}
g_list_free (layer_objects);
......@@ -2413,7 +2413,7 @@ ges_timeline_remove_layer (GESTimeline * timeline, GESTimelineLayer * layer)
g_signal_emit (timeline, ges_timeline_signals[LAYER_REMOVED], 0, layer);
g_object_unref (layer);
gst_object_unref (layer);
return TRUE;
}
......@@ -2492,7 +2492,7 @@ ges_timeline_add_track (GESTimeline * timeline, GESTrack * track)
GESClip *clip = obj->data;
add_object_to_tracks (timeline, clip, track);
g_object_unref (clip);
gst_object_unref (clip);
}
g_list_free (objects);
}
......@@ -2637,7 +2637,7 @@ ges_timeline_get_layers (GESTimeline * timeline)
GList *tmp, *res = NULL;
for (tmp = timeline->layers; tmp; tmp = g_list_next (tmp)) {
res = g_list_insert_sorted (res, g_object_ref (tmp->data),
res = g_list_insert_sorted (res, gst_object_ref (tmp->data),
(GCompareFunc) sort_layers);
}
......
......@@ -602,7 +602,7 @@ _child_removed (GESContainer * container, GESTimelineElement * element)
if (GES_IS_TITLE_SOURCE (element)) {
GST_DEBUG_OBJECT (container, "%" GST_PTR_FORMAT " removed", element);
priv->track_titles = g_slist_remove (priv->track_titles, element);
g_object_unref (element);
gst_object_unref (element);
}
}
......@@ -614,7 +614,7 @@ _child_added (GESContainer * container, GESTimelineElement * element)
if (GES_IS_TITLE_SOURCE (element)) {
GST_DEBUG_OBJECT (container, "%" GST_PTR_FORMAT " added", element);
priv->track_titles = g_slist_prepend (priv->track_titles,
g_object_ref (element));
gst_object_ref (element));
}
}
......@@ -659,7 +659,7 @@ ges_title_clip_new (void)
GESAsset *asset = ges_asset_request (GES_TYPE_TITLE_CLIP, NULL, NULL);
new_clip = GES_TITLE_CLIP (ges_asset_extract (asset, NULL));
g_object_unref (asset);
gst_object_unref (asset);
return new_clip;
}
......@@ -106,12 +106,12 @@ ges_title_source_dispose (GObject * object)
}
if (self->priv->text_el) {
g_object_unref (self->priv->text_el);
gst_object_unref (self->priv->text_el);
self->priv->text_el = NULL;
}
if (self->priv->background_el) {
g_object_unref (self->priv->background_el);
gst_object_unref (self->priv->background_el);
self->priv->background_el = NULL;
}
......@@ -175,8 +175,8 @@ ges_title_source_create_element (GESTrackElement * object)
src = gst_ghost_pad_new ("src", gst_element_get_static_pad (text, "src"));
gst_element_add_pad (topbin, src);
g_object_ref (text);
g_object_ref (background);
gst_object_ref (text);
gst_object_ref (background);
priv->text_el = text;
priv->background_el = background;
......
......@@ -923,7 +923,7 @@ ges_track_element_lookup_child (GESTrackElement * object,
g_strcmp0 (G_OBJECT_TYPE_NAME (G_OBJECT (value)), classename) == 0) {
GST_DEBUG ("The %s property from %s has been found", name, classename);
if (element)
*element = g_object_ref (value);
*element = gst_object_ref (value);
*pspec = g_param_spec_ref (key);
res = TRUE;
......@@ -1036,7 +1036,7 @@ ges_track_element_set_child_property_valist (GESTrackElement * object,
g_object_set_property (G_OBJECT (element), pspec->name, &value);
g_object_unref (element);
gst_object_unref (element);
g_value_unset (&value);
name = va_arg (var_args, gchar *);
......@@ -1120,7 +1120,7 @@ ges_track_element_get_child_property_valist (GESTrackElement * object,
g_value_init (&value, pspec->value_type);
g_object_get_property (G_OBJECT (element), pspec->name, &value);
g_object_unref (element);
gst_object_unref (element);
G_VALUE_LCOPY (&value, var_args, 0, &error);
if (error)
......@@ -1267,7 +1267,7 @@ ges_track_element_set_child_property (GESTrackElement * object,
g_object_set_property (G_OBJECT (element), pspec->name, value);
g_object_unref (element);
gst_object_unref (element);
g_param_spec_unref (pspec);
return TRUE;
......@@ -1316,7 +1316,7 @@ ges_track_element_get_child_property (GESTrackElement * object,
g_object_get_property (G_OBJECT (element), pspec->name, value);
g_object_unref (element);
gst_object_unref (element);
g_param_spec_unref (pspec);
return TRUE;
......
......@@ -95,7 +95,7 @@ static void composition_duration_cb (GstElement * composition, GParamSpec * arg
static void
add_trackelement_to_list_foreach (GESTrackElement * trackelement, GList ** list)
{
g_object_ref (trackelement);
gst_object_ref (trackelement);
*list = g_list_prepend (*list, trackelement);
}
......@@ -375,7 +375,7 @@ remove_object_internal (GESTrack * track, GESTrackElement * object)
g_signal_emit (track, ges_track_signals[TRACK_ELEMENT_REMOVED], 0,
GES_TRACK_ELEMENT (object));
g_object_unref (object);
gst_object_unref (object);
return TRUE;
}
......@@ -801,7 +801,7 @@ ges_track_get_elements (GESTrack * track)
* Removes the object from the track and unparents it.
* Unparenting it means the reference owned by @track on the @object will be
* removed. If you wish to use the @object after this function, make sure you
* call g_object_ref() before removing it from the @track.
* call gst_object_ref() before removing it from the @track.
*
* Returns: #TRUE if the object was removed, else #FALSE if the track
* could not remove the object (like if it didn't belong to the track).
......
......@@ -275,7 +275,7 @@ _child_removed (GESContainer * container, GESTimelineElement * element)
if (GES_IS_VIDEO_TRANSITION (element)) {
GST_DEBUG_OBJECT (container, "%" GST_PTR_FORMAT " removed", element);
priv->video_transitions = g_slist_remove (priv->video_transitions, element);
g_object_unref (element);
gst_object_unref (element);
}
}
......@@ -287,7 +287,7 @@ _child_added (GESContainer * container, GESTimelineElement * element)
if (GES_IS_VIDEO_TRANSITION (element)) {
GST_DEBUG_OBJECT (container, "%" GST_PTR_FORMAT " added", element);
priv->video_transitions =
g_slist_prepend (priv->video_transitions, g_object_ref (element));
g_slist_prepend (priv->video_transitions, gst_object_ref (element));
}
}
......
......@@ -144,13 +144,13 @@ _request_id_update (GESAsset * self, gchar ** proposed_new_id, GError * error)
*proposed_new_id = g_file_get_uri (new_file);
g_object_unref (new_file);
gst_object_unref (new_file);
g_free (basename);
}
g_object_unref (parent);
gst_object_unref (parent);
}
g_object_unref (file);
gst_object_unref (file);
return TRUE;
}
......@@ -168,8 +168,8 @@ _asset_proxied (GESAsset * self, const gchar * new_uri)
parent = g_file_get_parent (file);
new_parent = g_file_get_parent (new_file);
g_hash_table_insert (parent_newparent_table, parent, new_parent);
g_object_unref (file);
g_object_unref (new_file);
gst_object_unref (file);
gst_object_unref (new_file);
}
static void
......@@ -206,7 +206,7 @@ ges_uri_clip_asset_class_init (GESUriClipAssetClass * klass)