From 7d2c7c5881bd6bf6bae78062483aa63e8e918171 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Mon, 11 Oct 2010 20:06:04 +0000 Subject: [PATCH] Don't add garbage AssEntries for blank lines in the file. Fixes some issues with sorting lines. Originally committed to SVN as r4801. --- aegisub/src/ass_file.cpp | 4 +++- aegisub/src/subtitle_format_ass.cpp | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index 148f76c2f..6118340ca 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -279,6 +279,8 @@ bool AssFile::CanSave() { // I strongly advice you against touching this function unless you know what you're doing; // even moving things out of order might break ASS parsing - AMZ. void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGroup) { + if (data.empty()) return; + // Group AssEntry *entry = NULL; wxString origGroup = group; @@ -344,7 +346,7 @@ void AssFile::AddLine(wxString data,wxString group,int &version,wxString *outGro } // Dialogue - if (lowGroup == _T("[events]")) { + else if (lowGroup == _T("[events]")) { if (data.StartsWith(_T("Dialogue:")) || data.StartsWith(_T("Comment:"))) { AssDialogue *diag = new AssDialogue(data,version); //diag->ParseASSTags(); diff --git a/aegisub/src/subtitle_format_ass.cpp b/aegisub/src/subtitle_format_ass.cpp index 9439b7376..8bdbddd3d 100644 --- a/aegisub/src/subtitle_format_ass.cpp +++ b/aegisub/src/subtitle_format_ass.cpp @@ -136,9 +136,6 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) { // Not-so-special case for other groups, just set it else { curgroup = wxbuffer; - // default from extension in all other sections - //version = 1; - //if (filename.Right(4).Lower() == _T(".ssa")) version = 0; } } @@ -155,9 +152,6 @@ void ASSSubtitleFormat::ReadFile(wxString filename,wxString encoding) { throw wxString(_T("Error processing line: ")) + wxbuffer; } } - - // Add one last empty line in case it didn't end with one - if (!wxbuffer.IsEmpty()) AddLine(_T(""),curgroup,version); }