group: tidied timeline membership in copy-paste

Previously, the GESContainer ->paste method and GESGroup ->paste methods
were unnecessarily setting the timeline of groups, even though this is
handled by the GESGroup ->child_added method. This could result in the
group being added multiple times.
This commit is contained in:
Henry Wilkes 2020-04-02 11:58:18 +01:00
parent eec9c90a8c
commit ef1c0f0faa
3 changed files with 10 additions and 34 deletions

View file

@ -127,6 +127,7 @@ _free_mapping (ChildMapping * mapping)
ges_timeline_element_set_parent (child, NULL);
gst_object_unref (child);
}
g_slice_free (ChildMapping, mapping);
}
@ -344,14 +345,11 @@ _deep_copy (GESTimelineElement * element, GESTimelineElement * copy)
GESContainer *self = GES_CONTAINER (element), *ccopy = GES_CONTAINER (copy);
for (tmp = GES_CONTAINER_CHILDREN (element); tmp; tmp = tmp->next) {
ChildMapping *map;
map =
g_slice_dup (ChildMapping, g_hash_table_lookup (self->priv->mappings,
tmp->data));
ChildMapping *map, *orig_map;
orig_map = g_hash_table_lookup (self->priv->mappings, tmp->data);
map = g_slice_new0 (ChildMapping);
map->child = ges_timeline_element_copy (tmp->data, TRUE);
map->start_notifyid = 0;
map->duration_notifyid = 0;
map->start_offset = orig_map->start_offset;
ccopy->priv->copied_children = g_list_prepend (ccopy->priv->copied_children,
map);
@ -384,8 +382,7 @@ _paste (GESTimelineElement * element, GESTimelineElement * ref,
return NULL;
}
ges_timeline_element_set_timeline (GES_TIMELINE_ELEMENT (ncontainer),
GES_TIMELINE_ELEMENT_TIMELINE (ref));
/* for GESGroups, this may register the group on the timeline */
ges_container_add (ncontainer, nchild);
}

View file

@ -685,27 +685,6 @@ _group (GList * containers)
return ret;
}
static GESTimelineElement *
_paste (GESTimelineElement * element, GESTimelineElement * ref,
GstClockTime paste_position)
{
GESTimelineElement *ngroup =
GES_TIMELINE_ELEMENT_CLASS (parent_class)->paste (element, ref,
paste_position);
if (ngroup) {
if (GES_CONTAINER_CHILDREN (ngroup)) {
timeline_add_group (GES_TIMELINE_ELEMENT_TIMELINE (GES_CONTAINER_CHILDREN
(ngroup)->data), GES_GROUP (element));
timeline_emit_group_added (GES_TIMELINE_ELEMENT_TIMELINE
(GES_CONTAINER_CHILDREN (ngroup)->data), GES_GROUP (element));
}
}
return ngroup;
}
/****************************************************
* *
* GObject virtual methods implementation *
@ -781,7 +760,6 @@ ges_group_class_init (GESGroupClass * klass)
element_class->set_max_duration = _set_max_duration;
element_class->set_start = _set_start;
element_class->set_priority = _set_priority;
element_class->paste = _paste;
/* We override start, inpoint, duration and max-duration from GESTimelineElement
* in order to makes sure those fields are not serialized.

View file

@ -332,14 +332,15 @@ ges_timeline_dispose (GObject * object)
ges_timeline_remove_track (GES_TIMELINE (object), tl->tracks->data);
UNLOCK_DYN (tl);
groups = g_list_copy (priv->groups);
/* NOTE: the timeline should not contain empty groups */
groups = g_list_copy_deep (priv->groups, (GCopyFunc) gst_object_ref, NULL);
for (tmp = groups; tmp; tmp = tmp->next) {
GList *elems = ges_container_ungroup (tmp->data, FALSE);
g_list_free_full (elems, gst_object_unref);
}
g_list_free (priv->groups);
g_list_free (groups);
g_list_free_full (groups, gst_object_unref);
g_list_free_full (priv->groups, gst_object_unref);
g_list_free_full (priv->auto_transitions, gst_object_unref);