Get wxMessageBox out of AssFile

This commit is contained in:
Thomas Goyne 2012-10-11 20:18:47 -07:00
parent 33dd0abc7f
commit a53432736c
4 changed files with 17 additions and 19 deletions

View file

@ -82,10 +82,7 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
try {
// Get proper format reader
const SubtitleFormat *reader = SubtitleFormat::GetReader(_filename);
if (!reader) {
wxMessageBox("Unknown file type","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return;
}
if (!reader) throw "Unknown file type";
AssFile temp;
reader->ReadFile(&temp, _filename, charset);
@ -112,16 +109,6 @@ void AssFile::Load(const wxString &_filename, wxString charset, bool addToRecent
catch (agi::UserCancelException const&) {
return;
}
// Real exception
catch (agi::Exception &e) {
wxMessageBox(lagi_wxString(e.GetChainedMessage()), "Error loading file", wxOK | wxICON_ERROR | wxCENTER);
return;
}
// Other error
catch (...) {
wxMessageBox("Unknown error","Error loading file",wxOK | wxICON_ERROR | wxCENTER);
return;
}
// Set general data
loaded = true;

View file

@ -48,13 +48,9 @@
#include <libaegisub/signal.h>
class FrameRate;
class AssDialogue;
class AssStyle;
class AssAttachment;
class AssDialogueBlock;
class AssDialogueBlockOverride;
class AssDialogueBlockPlain;
class AssEntry;
typedef std::list<AssEntry*>::iterator entryIter;

View file

@ -600,7 +600,19 @@ void DialogStyleManager::OnCurrentImport() {
try {
temp.Load(filename, "", false);
}
catch (const char *err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (wxString const& err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (agi::Exception const& err) {
wxMessageBox(lagi_wxString(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
}
catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}

View file

@ -436,13 +436,16 @@ void FrameMain::LoadSubtitles(wxString filename,wxString charset) {
return;
}
catch (const char *err) {
wxMessageBox(wxString(err), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (wxString const& err) {
wxMessageBox(err, "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;
}
catch (agi::Exception const& err) {
wxMessageBox(lagi_wxString(err.GetChainedMessage()), "Error", wxOK | wxICON_ERROR | wxCENTER, this);
}
catch (...) {
wxMessageBox("Unknown error", "Error", wxOK | wxICON_ERROR | wxCENTER, this);
return;