Fix memory leak in VSE transform code

SeqCollection wasn't freed.

It wasn't easy to find culprit so added argument to
SEQ_collection_create() to pass function name.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D11746
This commit is contained in:
Richard Antalik 2021-07-01 22:14:29 +02:00
parent 519c12da41
commit b7b5c23b80
6 changed files with 15 additions and 14 deletions

View File

@ -281,7 +281,7 @@ static bool seq_transform_check_overlap(SeqCollection *transformed_strips)
static SeqCollection *extract_standalone_strips(SeqCollection *transformed_strips)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
Sequence *seq;
SEQ_ITERATOR_FOREACH (seq, transformed_strips) {
if ((seq->type & SEQ_TYPE_EFFECT) == 0 || seq->seq1 == NULL) {
@ -302,7 +302,7 @@ static SeqCollection *query_right_side_strips(ListBase *seqbase, SeqCollection *
}
}
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->flag & SELECT) == 0 && seq->startdisp >= minframe) {
SEQ_collection_append_strip(seq, collection);
@ -407,7 +407,7 @@ static void seq_transform_handle_overlap(TransInfo *t, SeqCollection *transforme
static SeqCollection *seq_transform_collection_from_transdata(TransDataContainer *tc)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
TransData *td = tc->data;
for (int a = 0; a < tc->data_len; a++, td++) {
Sequence *seq = ((TransDataSeq *)td->extra)->seq;
@ -428,6 +428,7 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c
if (t->state == TRANS_CANCEL) {
seq_transform_cancel(t, transformed_strips);
SEQ_collection_free(transformed_strips);
free_transform_custom_data(custom_data);
return;
}

View File

@ -108,7 +108,7 @@ static SeqCollection *query_snap_targets(const TransInfo *t)
{
const ListBase *seqbase = SEQ_active_seqbase_get(SEQ_editing_get(t->scene, false));
const short snap_flag = SEQ_tool_settings_snap_flag_get(t->scene);
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->flag & SELECT)) {
continue; /* Selected are being transformed. */

View File

@ -70,7 +70,7 @@ bool SEQ_iterator_ensure(SeqCollection *collection,
struct Sequence **r_seq);
struct Sequence *SEQ_iterator_yield(SeqIterator *iterator);
SeqCollection *SEQ_collection_create(void);
SeqCollection *SEQ_collection_create(const char *name);
uint SEQ_collection_len(const SeqCollection *collection);
bool SEQ_collection_append_strip(struct Sequence *seq, SeqCollection *data);
bool SEQ_collection_remove_strip(struct Sequence *seq, SeqCollection *data);

View File

@ -106,9 +106,9 @@ void SEQ_collection_free(SeqCollection *collection)
*
* \return empty strip collection.
*/
SeqCollection *SEQ_collection_create(void)
SeqCollection *SEQ_collection_create(const char *name)
{
SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), "SeqCollection");
SeqCollection *collection = MEM_callocN(sizeof(SeqCollection), name);
collection->set = BLI_gset_new(
BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SeqCollection GSet");
return collection;
@ -136,7 +136,7 @@ SeqCollection *SEQ_query_by_reference(Sequence *seq_reference,
ListBase *seqbase,
SeqCollection *collection))
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
seq_query_func(seq_reference, seqbase, collection);
return collection;
}
@ -223,7 +223,7 @@ void SEQ_collection_expand(ListBase *seqbase,
*/
SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if (seq->type == SEQ_TYPE_META) {
SEQ_collection_merge(collection, SEQ_query_all_strips_recursive(&seq->seqbase));
@ -241,7 +241,7 @@ SeqCollection *SEQ_query_all_strips_recursive(ListBase *seqbase)
*/
SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
SEQ_collection_append_strip(seq, collection);
}
@ -256,7 +256,7 @@ SeqCollection *SEQ_query_all_strips(ListBase *seqbase)
*/
SeqCollection *SEQ_query_selected_strips(ListBase *seqbase)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if ((seq->flag & SELECT) == 0) {
continue;

View File

@ -308,7 +308,7 @@ static bool must_render_strip(const Sequence *seq, SeqCollection *strips_at_time
static SeqCollection *query_strips_at_frame(ListBase *seqbase, const int timeline_frame)
{
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
LISTBASE_FOREACH (Sequence *, seq, seqbase) {
if (SEQ_time_strip_intersects_frame(seq, timeline_frame)) {

View File

@ -255,7 +255,7 @@ bool SEQ_edit_move_strip_to_meta(Scene *scene,
return false;
}
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(src_seq, collection);
SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);
@ -396,7 +396,7 @@ Sequence *SEQ_edit_strip_split(Main *bmain,
return NULL;
}
SeqCollection *collection = SEQ_collection_create();
SeqCollection *collection = SEQ_collection_create(__func__);
SEQ_collection_append_strip(seq, collection);
SEQ_collection_expand(seqbase, collection, SEQ_query_strip_effect_chain);