don't leaks caps and converted strings

Summary:
Valgrind reports trivial leakages related to handling
objects and their converted strings.

Reviewers: thiblahute

Differential Revision: https://phabricator.freedesktop.org/D303
This commit is contained in:
Justin Kim 2015-10-01 11:28:38 +02:00 committed by Thibault Saunier
parent c96d8c8c21
commit 61da5ad63c
6 changed files with 35 additions and 19 deletions

View file

@ -121,6 +121,7 @@ ges_audio_track_new (void)
{
GESAudioTrack *ret;
GstCaps *caps = gst_caps_from_string (DEFAULT_CAPS);
GstCaps *restriction_caps = gst_caps_from_string (DEFAULT_RESTRICTION_CAPS);
ret = g_object_new (GES_TYPE_AUDIO_TRACK, "caps", caps,
"track-type", GES_TRACK_TYPE_AUDIO, NULL);
@ -128,9 +129,10 @@ ges_audio_track_new (void)
ges_track_set_create_element_for_gap_func (GES_TRACK (ret),
create_element_for_raw_audio_gap);
ges_track_set_restriction_caps (GES_TRACK (ret),
gst_caps_from_string (DEFAULT_RESTRICTION_CAPS));
ges_track_set_restriction_caps (GES_TRACK (ret), restriction_caps);
gst_caps_unref (caps);
gst_caps_unref (restriction_caps);
return ret;
}

View file

@ -192,7 +192,7 @@ done:
g_free (xmlcontent);
if (file)
gst_object_unref (file);
g_object_unref (file);
return parsecontext;
@ -204,6 +204,9 @@ wrong_uri:
failed:
g_propagate_error (error, err);
if (file)
g_object_unref (file);
if (parsecontext) {
g_markup_parse_context_free (parsecontext);
parsecontext = NULL;
@ -478,7 +481,7 @@ static gboolean
_loading_done_cb (GESFormatter * self)
{
_loading_done (self);
g_object_unref (self);
gst_object_unref (self);
return FALSE;
}
@ -1007,9 +1010,6 @@ ges_base_xml_formatter_add_track (GESBaseXmlFormatter * self,
GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);
if (priv->check_only) {
if (caps)
gst_caps_unref (caps);
return;
}
@ -1018,18 +1018,20 @@ ges_base_xml_formatter_add_track (GESBaseXmlFormatter * self,
if (properties) {
gchar *restriction;
GstCaps *caps;
GstCaps *restriction_caps;
gst_structure_get (properties, "restriction-caps", G_TYPE_STRING,
&restriction, NULL);
gst_structure_remove_fields (properties, "restriction-caps", "caps",
"message-forward", NULL);
if (g_strcmp0 (restriction, "NULL")) {
caps = gst_caps_from_string (restriction);
ges_track_set_restriction_caps (track, caps);
restriction_caps = gst_caps_from_string (restriction);
ges_track_set_restriction_caps (track, restriction_caps);
gst_caps_unref (restriction_caps);
}
gst_structure_foreach (properties,
(GstStructureForeachFunc) set_property_foreach, track);
g_free (restriction);
}
g_hash_table_insert (priv->tracks, g_strdup (id), gst_object_ref (track));

View file

@ -136,7 +136,7 @@ ges_extractable_set_asset (GESExtractable * self, GESAsset * asset)
* ges_extractable_get_id:
* @self: The #GESExtractable
*
* Returns: The #id of the associated #GESAsset, free with #g_free
* Returns: (transfer full) The #id of the associated #GESAsset, free with #g_free
*/
gchar *
ges_extractable_get_id (GESExtractable * self)

View file

@ -183,7 +183,7 @@ ges_multi_file_source_create_source (GESTrackElement * track_element)
g_assert (stream_info);
disc_caps = gst_discoverer_stream_info_get_caps (stream_info);
caps = gst_caps_copy (disc_caps);
GST_DEBUG ("Got some nice caps %s", gst_caps_to_string (disc_caps));
GST_DEBUG_OBJECT (disc_caps, "Got some nice caps");
gst_object_unref (stream_info);
gst_caps_unref (disc_caps);
} else {

View file

@ -56,6 +56,7 @@ _sync_capsfilter_with_track (GESTrack * track, GstElement * capsfilter)
fps_d, NULL);
g_object_set (capsfilter, "caps", caps, NULL);
gst_caps_unref (caps);
}
static void

View file

@ -344,6 +344,8 @@ _parse_track (GMarkupParseContext * context, const gchar * element_name,
if (props)
gst_structure_free (props);
gst_caps_unref (caps);
return;
wrong_caps:
@ -879,10 +881,12 @@ _serialize_properties (GObject * object, const gchar * fieldname, ...)
spec = pspecs[j];
if (spec->value_type == GST_TYPE_CAPS) {
GstCaps *caps;
gchar *caps_str;
g_object_get (object, spec->name, &caps, NULL);
gst_structure_set (structure, spec->name, G_TYPE_STRING,
gst_caps_to_string (caps), NULL);
caps_str = gst_caps_to_string (caps);
gst_structure_set (structure, spec->name, G_TYPE_STRING, caps_str, NULL);
g_free (caps_str);
} else if (_can_serialize_spec (spec)) {
_init_value_from_spec_for_serialization (&val, spec);
g_object_get_property (object, spec->name, &val);
@ -962,6 +966,7 @@ _save_children_properties (GString * str, GESTrackElement * trackelement)
GstStructure *structure;
GParamSpec **pspecs, *spec;
guint i, n_props;
gchar *struct_str;
pspecs = ges_track_element_list_children_properties (trackelement, &n_props);
@ -980,11 +985,11 @@ _save_children_properties (GString * str, GESTrackElement * trackelement)
}
g_free (pspecs);
struct_str = gst_structure_to_string (structure);
append_escaped (str,
g_markup_printf_escaped (" children-properties='%s'",
gst_structure_to_string (structure)));
g_markup_printf_escaped (" children-properties='%s'", struct_str));
gst_structure_free (structure);
g_free (struct_str);
}
/* TODO : Use this function for every track element with controllable properties */
@ -1054,6 +1059,7 @@ _save_effect (GString * str, guint clip_id, GESTrackElement * trackelement,
gchar *properties, *metas;
guint track_id = 0;
gboolean serialize;
gchar *extractable_id;
g_object_get (trackelement, "serialize", &serialize, NULL);
if (!serialize) {
@ -1082,12 +1088,14 @@ _save_effect (GString * str, guint clip_id, GESTrackElement * trackelement,
"in-point", "duration", "locked", "max-duration", "name", NULL);
metas =
ges_meta_container_metas_to_string (GES_META_CONTAINER (trackelement));
extractable_id = ges_extractable_get_id (GES_EXTRACTABLE (trackelement));
append_escaped (str,
g_markup_printf_escaped (" <effect asset-id='%s' clip-id='%u'"
" type-name='%s' track-type='%i' track-id='%i' properties='%s' metadatas='%s'",
ges_extractable_get_id (GES_EXTRACTABLE (trackelement)), clip_id,
extractable_id, clip_id,
g_type_name (G_OBJECT_TYPE (trackelement)), tck->type, track_id,
properties, metas));
g_free (extractable_id);
g_free (properties);
g_free (metas);
@ -1128,6 +1136,7 @@ _save_layers (GESXmlFormatter * self, GString * str, GESTimeline * timeline)
GList *tmptrackelement;
GList *tracks;
gboolean serialize;
gchar *extractable_id;
clip = GES_CLIP (tmpclip->data);
@ -1144,15 +1153,17 @@ _save_layers (GESXmlFormatter * self, GString * str, GESTimeline * timeline)
properties = _serialize_properties (G_OBJECT (clip),
"supported-formats", "rate", "in-point", "start", "duration",
"max-duration", "priority", "vtype", "uri", NULL);
extractable_id = ges_extractable_get_id (GES_EXTRACTABLE (clip));
append_escaped (str,
g_markup_printf_escaped (" <clip id='%i' asset-id='%s'"
" type-name='%s' layer-priority='%i' track-types='%i' start='%"
G_GUINT64_FORMAT "' duration='%" G_GUINT64_FORMAT "' inpoint='%"
G_GUINT64_FORMAT "' rate='%d' properties='%s' >\n",
priv->nbelements, ges_extractable_get_id (GES_EXTRACTABLE (clip)),
priv->nbelements, extractable_id,
g_type_name (G_OBJECT_TYPE (clip)), priority,
ges_clip_get_supported_formats (clip), _START (clip),
_DURATION (clip), _INPOINT (clip), 0, properties));
g_free (extractable_id);
g_free (properties);
g_hash_table_insert (self->priv->element_id, clip,