Handle modeless dialogs which never fully open

Fixes crash when opening the spell checker dialog after no spelling
errors were found previously.

Closes #1491.

Originally committed to SVN as r6824.
This commit is contained in:
Thomas Goyne 2012-05-18 14:01:56 +00:00
parent 904b5aafe4
commit c7fb7eb295
2 changed files with 12 additions and 9 deletions

View File

@ -69,10 +69,13 @@ public:
it->second->SetFocus(); it->second->SetFocus();
} }
else { else {
wxDialog *d = new DialogType(c); try {
created_dialogs[&typeid(DialogType)] = d; wxDialog *d = new DialogType(c);
d->Bind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this); created_dialogs[&typeid(DialogType)] = d;
d->Show(); d->Bind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this);
d->Show();
}
catch (agi::UserCancelException const&) { }
} }
} }

View File

@ -48,6 +48,8 @@
#include "subs_edit_ctrl.h" #include "subs_edit_ctrl.h"
#include "utils.h" #include "utils.h"
#include <libaegisub/exception.h>
static void save_skip_comments(wxCommandEvent &evt) { static void save_skip_comments(wxCommandEvent &evt) {
OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt());
} }
@ -93,15 +95,13 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context)
{ {
if (!spellchecker.get()) { if (!spellchecker.get()) {
wxMessageBox("No spellchecker available.", "Error", wxOK | wxICON_ERROR | wxCENTER); wxMessageBox("No spellchecker available.", "Error", wxOK | wxICON_ERROR | wxCENTER);
Destroy(); throw agi::UserCancelException("No spellchecker available");
return;
} }
dictionary_lang_codes = spellchecker->GetLanguageList(); dictionary_lang_codes = spellchecker->GetLanguageList();
if (dictionary_lang_codes.empty()) { if (dictionary_lang_codes.empty()) {
wxMessageBox("No spellchecker dictionaries available.", "Error", wxOK | wxICON_ERROR | wxCENTER); wxMessageBox("No spellchecker dictionaries available.", "Error", wxOK | wxICON_ERROR | wxCENTER);
Destroy(); throw agi::UserCancelException("No spellchecker dictionaries available");
return;
} }
wxArrayString language_names(dictionary_lang_codes); wxArrayString language_names(dictionary_lang_codes);
@ -238,7 +238,7 @@ bool DialogSpellChecker::FindNext() {
} }
else { else {
wxMessageBox(_("Aegisub has found no spelling mistakes in this script."), _("Spell checking complete.")); wxMessageBox(_("Aegisub has found no spelling mistakes in this script."), _("Spell checking complete."));
Destroy(); throw agi::UserCancelException("No spelling mistakes");
} }
return false; return false;