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/editors/space_sequencer/sequencer_edit.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/editors/space_sequencer/sequencer_edit.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 694e5fbb41d..935bc97d0b2 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -2980,6 +2980,22 @@ static int sequencer_export_subtitles_invoke(bContext *C,
return OPERATOR_RUNNING_MODAL;
}
+typedef struct Seq_get_text_cb_data {
+ ListBase *text_seq;
+ Scene *scene;
+} Seq_get_text_cb_data;
+
+static bool seq_get_text_strip_cb(Sequence *seq, void *user_data)
+{
+ Seq_get_text_cb_data *cd = (Seq_get_text_cb_data *)user_data;
+ /* Only text strips that are not muted and don't end with negative frame. */
+ if ((seq->type == SEQ_TYPE_TEXT) && ((seq->flag & SEQ_MUTE) == 0) &&
+ (seq->enddisp > cd->scene->r.sfra)) {
+ BLI_addtail(cd->text_seq, MEM_dupallocN(seq));
+ }
+ return true;
+}
+
static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
@@ -3011,14 +3027,10 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* Only text strips that are not muted and don't end with negative frame. */
- SEQ_ALL_BEGIN (ed, seq) {
- if ((seq->type == SEQ_TYPE_TEXT) && ((seq->flag & SEQ_MUTE) == 0) &&
- (seq->enddisp > scene->r.sfra)) {
- BLI_addtail(&text_seq, MEM_dupallocN(seq));
- }
+ if (ed != NULL) {
+ Seq_get_text_cb_data cb_data = {&text_seq, scene};
+ SEQ_for_each_callback(&ed->seqbase, seq_get_text_strip_cb, &cb_data);
}
- SEQ_ALL_END;
if (BLI_listbase_is_empty(&text_seq)) {
BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");