From c7fb7eb295062eebe569a5bedb81f0318185a863 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 18 May 2012 14:01:56 +0000 Subject: [PATCH] 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. --- aegisub/src/dialog_manager.h | 11 +++++++---- aegisub/src/dialog_spellchecker.cpp | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/aegisub/src/dialog_manager.h b/aegisub/src/dialog_manager.h index 461cb358e..3d8222ac7 100644 --- a/aegisub/src/dialog_manager.h +++ b/aegisub/src/dialog_manager.h @@ -69,10 +69,13 @@ public: it->second->SetFocus(); } else { - wxDialog *d = new DialogType(c); - created_dialogs[&typeid(DialogType)] = d; - d->Bind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this); - d->Show(); + try { + wxDialog *d = new DialogType(c); + created_dialogs[&typeid(DialogType)] = d; + d->Bind(wxEVT_CLOSE_WINDOW, &DialogManager::OnClose, this); + d->Show(); + } + catch (agi::UserCancelException const&) { } } } diff --git a/aegisub/src/dialog_spellchecker.cpp b/aegisub/src/dialog_spellchecker.cpp index de7a94268..a68fce2e0 100644 --- a/aegisub/src/dialog_spellchecker.cpp +++ b/aegisub/src/dialog_spellchecker.cpp @@ -48,6 +48,8 @@ #include "subs_edit_ctrl.h" #include "utils.h" +#include + static void save_skip_comments(wxCommandEvent &evt) { OPT_SET("Tool/Spell Checker/Skip Comments")->SetBool(!!evt.GetInt()); } @@ -93,15 +95,13 @@ DialogSpellChecker::DialogSpellChecker(agi::Context *context) { if (!spellchecker.get()) { wxMessageBox("No spellchecker available.", "Error", wxOK | wxICON_ERROR | wxCENTER); - Destroy(); - return; + throw agi::UserCancelException("No spellchecker available"); } dictionary_lang_codes = spellchecker->GetLanguageList(); if (dictionary_lang_codes.empty()) { wxMessageBox("No spellchecker dictionaries available.", "Error", wxOK | wxICON_ERROR | wxCENTER); - Destroy(); - return; + throw agi::UserCancelException("No spellchecker dictionaries available"); } wxArrayString language_names(dictionary_lang_codes); @@ -238,7 +238,7 @@ bool DialogSpellChecker::FindNext() { } else { wxMessageBox(_("Aegisub has found no spelling mistakes in this script."), _("Spell checking complete.")); - Destroy(); + throw agi::UserCancelException("No spelling mistakes"); } return false;