From f49d438ced7c5874dbf43976d9901a462176f541 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Fri, 20 Aug 2021 16:30:34 +0200 Subject: Cleanup and remove SEQ_ALL_BEGIN macro We now use a for_each function with callback to iterate through all sequences in the scene. This has the benefit that we now only loop over the sequences in the scene once. Before we would loop over them twice and allocate memory to store temporary data. The allocation of temporary data lead to unintentional memory leaks if the code used returns to exit out of the iteration loop. The new for_each callback method doesn't allocate any temporary data and only iterates though all sequences once. Reviewed By: Richard Antalik, Bastien Montagne Differential Revision: http://developer.blender.org/D12278 --- .../blender/blenloader/intern/versioning_legacy.c | 32 +++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'source/blender/blenloader/intern/versioning_legacy.c') diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 6ba27b6ee9e..62cc2aa3662 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -482,6 +482,22 @@ void blo_do_version_old_trackto_to_constraints(Object *ob) ob->track = NULL; } +static bool seq_set_alpha_mode_cb(Sequence *seq, void *UNUSED(user_data)) +{ + if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) { + seq->alpha_mode = SEQ_ALPHA_STRAIGHT; + } + return true; +} + +static bool seq_set_blend_mode_cb(Sequence *seq, void *UNUSED(user_data)) +{ + if (seq->blend_mode == 0) { + seq->blend_opacity = 100.0f; + } + return true; +} + /* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) { @@ -1228,7 +1244,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (bmain->versionfile <= 235) { Tex *tex = bmain->textures.first; Scene *sce = bmain->scenes.first; - Sequence *seq; Editing *ed; while (tex) { @@ -1240,12 +1255,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) while (sce) { ed = sce->ed; if (ed) { - SEQ_ALL_BEGIN (sce->ed, seq) { - if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) { - seq->alpha_mode = SEQ_ALPHA_STRAIGHT; - } - } - SEQ_ALL_END; + SEQ_for_each_callback(&sce->ed->seqbase, seq_set_alpha_mode_cb, NULL); } sce = sce->id.next; @@ -2404,15 +2414,11 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) if (!MAIN_VERSION_ATLEAST(bmain, 245, 14)) { Scene *sce; - Sequence *seq; for (sce = bmain->scenes.first; sce; sce = sce->id.next) { - SEQ_ALL_BEGIN (sce->ed, seq) { - if (seq->blend_mode == 0) { - seq->blend_opacity = 100.0f; - } + if (sce->ed) { + SEQ_for_each_callback(&sce->ed->seqbase, seq_set_blend_mode_cb, NULL); } - SEQ_ALL_END; } } -- cgit v1.2.3