asset: unref requested assets

Prevent a few memory leaks in the tests.

Also mark ges_project_save as transfer full for the formatter asset.

Also make sure that ges_project_request_sync is transfer full on the
returned asset.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/issues/104

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>
This commit is contained in:
Henry Wilkes 2020-05-01 12:40:58 +01:00
parent 0fab5f45cb
commit 9161c2efcb
6 changed files with 16 additions and 4 deletions

View file

@ -872,7 +872,7 @@ ges_project_create_asset_sync (GESProject * project, const gchar * id,
if ((asset = g_hash_table_lookup (project->priv->assets, internal_id))) {
g_free (internal_id);
return asset;
return gst_object_ref (asset);
} else if (g_hash_table_lookup (project->priv->loading_assets, internal_id) ||
g_hash_table_lookup (project->priv->loaded_with_error, internal_id)) {
g_free (internal_id);
@ -1059,9 +1059,10 @@ ges_project_list_assets (GESProject * project, GType filter)
* @project: A #GESProject to save
* @timeline: The #GESTimeline to save, it must have been extracted from @project
* @uri: The uri where to save @project and @timeline
* @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
* will try to save in the same format as the one from which the timeline as been loaded
* or default to the best formatter as defined in #ges_find_formatter_for_uri
* @formatter_asset: (transfer full) (allow-none): The formatter asset to
* use or %NULL. If %NULL, will try to save in the same format as the one
* from which the timeline as been loaded or default to the best formatter
* as defined in #ges_find_formatter_for_uri
* @overwrite: %TRUE to overwrite file if it exists
* @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
*

View file

@ -240,6 +240,9 @@ GST_START_TEST (test_uri_clip_change_asset)
g_free (uri);
g_free (uri1);
gst_object_unref (asset1);
gst_object_unref (asset);
ges_deinit ();
}

View file

@ -395,6 +395,7 @@ GST_START_TEST (test_gap_filling_empty_track)
gap_object_check (gap, 0, 10, 1);
fail_unless (ges_timeline_commit (timeline));
gst_object_unref (asset);
gst_object_unref (timeline);
}

View file

@ -1037,6 +1037,7 @@ GST_START_TEST (test_clip_group_ungroup)
assert_num_in_track (video_track, 3);
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}
@ -1538,6 +1539,7 @@ GST_START_TEST (test_adding_children_to_track)
ges_clip_get_top_effect_index (clip, GES_BASE_EFFECT (effect2)));
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}

View file

@ -716,6 +716,7 @@ GST_START_TEST (test_group_serialization)
g_free (tmpuri);
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}
@ -848,6 +849,7 @@ GST_START_TEST (test_children_properties_contain)
free_children_properties (child_props2, num_props2);
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}

View file

@ -460,6 +460,7 @@ GST_START_TEST (test_single_layer_automatic_transition)
g_list_free_full (objects, gst_object_unref);
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}
@ -928,6 +929,7 @@ GST_START_TEST (test_multi_layer_automatic_transition)
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}
@ -1162,6 +1164,7 @@ GST_START_TEST (test_layer_activate_automatic_transition)
gst_object_unref (timeline);
gst_object_unref (asset);
ges_deinit ();
}