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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-10-04 17:42:19 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-04 17:43:24 +0300
commitf2499b601514755819c2db4876b8ec677b45285e (patch)
tree102c0616e53445cd4b6777f42b286ea7cc5ce2ee /source/blender/editors/space_sequencer/sequencer_edit.c
parentc919ce3aa9684b88849d5628e629c3a1ac87e40b (diff)
Fix T46368: Subtitle Export: Subtitles are not sorted by time.
We need a temp list of Text effect strips here, to be able to sort it as we want...
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_edit.c')
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 88a2f386b9b..fb52da31d20 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -3859,7 +3859,9 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Sequence *seq = BKE_sequencer_active_get(scene);
+ Sequence *seq_next;
Editing *ed = BKE_sequencer_editing_get(scene, false);
+ ListBase text_seq = {0};
int iter = 0;
FILE *file;
char filepath[FILE_MAX];
@@ -3885,26 +3887,40 @@ static int sequencer_export_subtitles_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
- /* time to open and write! */
- file = BLI_fopen(filepath, "w");
-
SEQ_BEGIN(ed, seq)
{
if (seq->type == SEQ_TYPE_TEXT) {
- TextVars *data = seq->effectdata;
- char timecode_str_start[32];
- char timecode_str_end[32];
-
- BLI_timecode_string_from_time(timecode_str_start, sizeof(timecode_str_start),
- -2, FRA2TIME(seq->startdisp), FPS, USER_TIMECODE_SUBRIP);
- BLI_timecode_string_from_time(timecode_str_end, sizeof(timecode_str_end),
- -2, FRA2TIME(seq->enddisp), FPS, USER_TIMECODE_SUBRIP);
-
- fprintf(file, "%d\n%s --> %s\n%s\n\n", iter++, timecode_str_start, timecode_str_end, data->text);
+ BLI_addtail(&text_seq, MEM_dupallocN(seq));
}
}
SEQ_END
+ if (BLI_listbase_is_empty(&text_seq)) {
+ BKE_report(op->reports, RPT_ERROR, "No subtitles (text strips) to export");
+ return OPERATOR_CANCELLED;
+ }
+
+ BLI_listbase_sort(&text_seq, BKE_sequencer_cmp_time_startdisp);
+
+ /* time to open and write! */
+ file = BLI_fopen(filepath, "w");
+
+ for (seq = text_seq.first; seq; seq = seq_next) {
+ TextVars *data = seq->effectdata;
+ char timecode_str_start[32];
+ char timecode_str_end[32];
+
+ BLI_timecode_string_from_time(timecode_str_start, sizeof(timecode_str_start),
+ -2, FRA2TIME(seq->startdisp), FPS, USER_TIMECODE_SUBRIP);
+ BLI_timecode_string_from_time(timecode_str_end, sizeof(timecode_str_end),
+ -2, FRA2TIME(seq->enddisp), FPS, USER_TIMECODE_SUBRIP);
+
+ fprintf(file, "%d\n%s --> %s\n%s\n\n", iter++, timecode_str_start, timecode_str_end, data->text);
+
+ seq_next = seq->next;
+ MEM_freeN(seq);
+ }
+
fclose(file);
return OPERATOR_FINISHED;