From 3ce80afadf9235af767066598440579d83f865a2 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Fri, 15 May 2009 01:34:00 +0000 Subject: [PATCH] Fix #809, properly close all SRT overrides during export and ensure overrides in recombined lines do not affect each other (per the example I gave in the report.) Originally committed to SVN as r2934. --- aegisub/src/ass_dialogue.cpp | 10 ++++++++++ aegisub/src/subtitle_format_srt.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/aegisub/src/ass_dialogue.cpp b/aegisub/src/ass_dialogue.cpp index ae6187101..ff504bd17 100644 --- a/aegisub/src/ass_dialogue.cpp +++ b/aegisub/src/ass_dialogue.cpp @@ -671,6 +671,16 @@ void AssDialogue::ConvertTagsToSRT () { } } + // Ensure all tags are closed + if (isBold) + final += _T(""); + if (isItalic) + final += _T(""); + if (isUnder) + final += _T(""); + if (isStrike) + final += _T(""); + Text = final; UpdateData(); ClearBlocks(); diff --git a/aegisub/src/subtitle_format_srt.cpp b/aegisub/src/subtitle_format_srt.cpp index db3328fec..5c96369db 100644 --- a/aegisub/src/subtitle_format_srt.cpp +++ b/aegisub/src/subtitle_format_srt.cpp @@ -184,9 +184,15 @@ void SRTSubtitleFormat::WriteFile(wxString _filename,wxString encoding) { CreateCopy(); SortLines(); StripComments(); + // Tags must be converted in two passes + // First ASS style overrides are converted to SRT but linebreaks are kept + ConvertTags(2,_T("\\N")); + // Then we can recombine overlaps, this requires ASS style linebreaks RecombineOverlaps(); MergeIdentical(); - ConvertTags(2,_T("\r\n")); + // And finally convert linebreaks + ConvertTags(0,_T("\r\n")); + // Otherwise unclosed overrides might affect lines they shouldn't, see bug #809 for example // Write lines int i=1;