From 51a3831794bef1b878268c1f6af01185ab21b744 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 10 Feb 2012 00:04:05 +0000 Subject: [PATCH] Remove charset detection from AssFile::Load All of the subtitle formats also already do charset detection when needed, so doing it in it AssFile::Load is pointless and results in performing the auto-detection even when it's pointless (because the format isn't text-based or always uses a single encoding). Originally committed to SVN as r6459. --- aegisub/src/ass_file.cpp | 13 ++----------- aegisub/src/subtitle_format_microdvd.cpp | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/aegisub/src/ass_file.cpp b/aegisub/src/ass_file.cpp index f5f18170a..ca3cd6cc3 100644 --- a/aegisub/src/ass_file.cpp +++ b/aegisub/src/ass_file.cpp @@ -51,7 +51,6 @@ #include "ass_file.h" #include "ass_override.h" #include "ass_style.h" -#include "charset_detect.h" #include "compat.h" #include "main.h" #include "standard_paths.h" @@ -79,21 +78,15 @@ AssFile::~AssFile() { } /// @brief Load generic subs -void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent) { +void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent) { try { - if (charset.empty()) { - charset = CharSetDetect::GetEncoding(_filename); - } - // Get proper format reader const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename); - if (!reader) { wxMessageBox("Unknown file type","Error loading file",wxICON_ERROR | wxOK); return; } - // Read file AssFile temp; reader->ReadFile(&temp, _filename, charset); swap(temp); @@ -106,7 +99,6 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent) wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxICON_ERROR|wxOK); return; } - // Other error catch (...) { wxMessageBox("Unknown error","Error loading file",wxICON_ERROR | wxOK); @@ -116,8 +108,7 @@ void AssFile::Load(const wxString &_filename,wxString charset,bool addToRecent) // Set general data loaded = true; filename = _filename; - wxFileName fn(filename); - StandardPaths::SetPathValue("?script", fn.GetPath()); + StandardPaths::SetPathValue("?script", wxFileName(filename).GetPath()); // Save backup of file if (CanSave() && OPT_GET("App/Auto/Backup")->GetBool()) { diff --git a/aegisub/src/subtitle_format_microdvd.cpp b/aegisub/src/subtitle_format_microdvd.cpp index a78c38422..9fc493044 100644 --- a/aegisub/src/subtitle_format_microdvd.cpp +++ b/aegisub/src/subtitle_format_microdvd.cpp @@ -79,7 +79,7 @@ bool MicroDVDSubtitleFormat::CanReadFile(wxString const& filename) const { } void MicroDVDSubtitleFormat::ReadFile(AssFile *target, wxString const& filename, wxString const& encoding) const { - TextFileReader file(filename); + TextFileReader file(filename, encoding); wxRegEx exp("^[\\{\\[]([0-9]+)[\\}\\]][\\{\\[]([0-9]+)[\\}\\]](.*)$", wxRE_ADVANCED); target->LoadDefault(false);