diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2021-08-20 17:30:34 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2021-08-25 18:30:39 +0300 |
commit | f49d438ced7c5874dbf43976d9901a462176f541 (patch) | |
tree | fae7b745eaf1e793b53119f3ec27c34621727c58 /source/blender/blenloader/intern/versioning_270.c | |
parent | 796035ad930383c26302ab6a57e8e6c90394603b (diff) |
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
Diffstat (limited to 'source/blender/blenloader/intern/versioning_270.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 79 |
1 files changed, 43 insertions, 36 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 1d46c0d5790..6492f0d1f69 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -425,6 +425,45 @@ static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id), } } +static bool seq_update_proxy_cb(Sequence *seq, void *UNUSED(user_data)) +{ + seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format"); + +#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19) +#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21) + if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) { + if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { + seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR; + } + if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { + seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE; + } + } +#undef SEQ_USE_PROXY_CUSTOM_DIR +#undef SEQ_USE_PROXY_CUSTOM_FILE + return true; +} + +static bool seq_update_effectdata_cb(Sequence *seq, void *UNUSED(user_data)) +{ + + if (seq->type != SEQ_TYPE_TEXT) { + return true; + } + + if (seq->effectdata == NULL) { + struct SeqEffectHandle effect_handle = SEQ_effect_handle_get(seq); + effect_handle.init(seq); + } + + TextVars *data = seq->effectdata; + if (data->color[3] == 0.0f) { + copy_v4_fl(data->color, 1.0f); + data->shadow_color[3] = 1.0f; + } + return true; +} + /* NOLINTNEXTLINE: readability-function-size */ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) { @@ -908,8 +947,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) Image *ima; for (scene = bmain->scenes.first; scene; scene = scene->id.next) { - Sequence *seq; - BKE_scene_add_render_view(scene, STEREO_LEFT_NAME); srv = scene->r.views.first; BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix)); @@ -918,23 +955,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) srv = scene->r.views.last; BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix)); - SEQ_ALL_BEGIN (scene->ed, seq) { - seq->stereo3d_format = MEM_callocN(sizeof(Stereo3dFormat), "Stereo Display 3d Format"); - -#define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19) -#define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21) - if (seq->strip && seq->strip->proxy && !seq->strip->proxy->storage) { - if (seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) { - seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_DIR; - } - if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { - seq->strip->proxy->storage = SEQ_STORAGE_PROXY_CUSTOM_FILE; - } - } -#undef SEQ_USE_PROXY_CUSTOM_DIR -#undef SEQ_USE_PROXY_CUSTOM_FILE + if (scene->ed) { + SEQ_for_each_callback(&scene->ed->seqbase, seq_update_proxy_cb, NULL); } - SEQ_ALL_END; } for (screen = bmain->screens.first; screen; screen = screen->id.next) { @@ -1215,25 +1238,9 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) } for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - Sequence *seq; - - SEQ_ALL_BEGIN (scene->ed, seq) { - if (seq->type != SEQ_TYPE_TEXT) { - continue; - } - - if (seq->effectdata == NULL) { - struct SeqEffectHandle effect_handle = SEQ_effect_handle_get(seq); - effect_handle.init(seq); - } - - TextVars *data = seq->effectdata; - if (data->color[3] == 0.0f) { - copy_v4_fl(data->color, 1.0f); - data->shadow_color[3] = 1.0f; - } + if (scene->ed) { + SEQ_for_each_callback(&scene->ed->seqbase, seq_update_effectdata_cb, NULL); } - SEQ_ALL_END; } /* Adding "Properties" region to DopeSheet */ |