Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2021-08-20 17:30:34 +0300
committerSebastian Parborg <darkdefende@gmail.com>2021-08-25 18:30:39 +0300
commitf49d438ced7c5874dbf43976d9901a462176f541 (patch)
treefae7b745eaf1e793b53119f3ec27c34621727c58 /source/blender/makesrna/intern/rna_color.c
parent796035ad930383c26302ab6a57e8e6c90394603b (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/makesrna/intern/rna_color.c')
-rw-r--r--source/blender/makesrna/intern/rna_color.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c
index 5f198a8ed4c..1ac6dd021e9 100644
--- a/source/blender/makesrna/intern/rna_color.c
+++ b/source/blender/makesrna/intern/rna_color.c
@@ -597,6 +597,27 @@ static const EnumPropertyItem *rna_ColorManagedColorspaceSettings_colorspace_ite
return items;
}
+typedef struct Seq_colorspace_cb_data {
+ ColorManagedColorspaceSettings *colorspace_settings;
+ Sequence *r_seq;
+} Seq_colorspace_cb_data;
+
+static bool seq_find_colorspace_settings_cb(Sequence *seq, void *user_data)
+{
+ Seq_colorspace_cb_data *cd = (Seq_colorspace_cb_data *)user_data;
+ if (seq->strip && &seq->strip->colorspace_settings == cd->colorspace_settings) {
+ cd->r_seq = seq;
+ return false;
+ }
+ return true;
+}
+
+static bool seq_free_anim_cb(Sequence *seq, void *UNUSED(user_data))
+{
+ SEQ_relations_sequence_free_anim(seq);
+ return true;
+}
+
static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
Scene *UNUSED(scene),
PointerRNA *ptr)
@@ -629,20 +650,14 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
if (scene->ed) {
ColorManagedColorspaceSettings *colorspace_settings = (ColorManagedColorspaceSettings *)
ptr->data;
- Sequence *seq;
- bool seq_found = false;
+ Seq_colorspace_cb_data cb_data = {colorspace_settings, NULL};
if (&scene->sequencer_colorspace_settings != colorspace_settings) {
- SEQ_ALL_BEGIN (scene->ed, seq) {
- if (seq->strip && &seq->strip->colorspace_settings == colorspace_settings) {
- seq_found = true;
- break;
- }
- }
- SEQ_ALL_END;
+ SEQ_for_each_callback(&scene->ed->seqbase, seq_find_colorspace_settings_cb, &cb_data);
}
+ Sequence *seq = cb_data.r_seq;
- if (seq_found) {
+ if (seq) {
SEQ_relations_sequence_free_anim(seq);
if (seq->strip->proxy && seq->strip->proxy->anim) {
@@ -653,10 +668,7 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *bmain,
SEQ_relations_invalidate_cache_raw(scene, seq);
}
else {
- SEQ_ALL_BEGIN (scene->ed, seq) {
- SEQ_relations_sequence_free_anim(seq);
- }
- SEQ_ALL_END;
+ SEQ_for_each_callback(&scene->ed->seqbase, seq_free_anim_cb, NULL);
}
WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, NULL);