diff --git a/aegisub/src/subs_edit_ctrl.cpp b/aegisub/src/subs_edit_ctrl.cpp index 44c5efc59..970acff67 100644 --- a/aegisub/src/subs_edit_ctrl.cpp +++ b/aegisub/src/subs_edit_ctrl.cpp @@ -85,6 +85,7 @@ enum { SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context) : ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style) , spellchecker(SpellCheckerFactory::GetSpellChecker()) +, thesaurus(agi::util::make_unique()) , context(context) { // Set properties @@ -387,9 +388,6 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { if (currentWord.empty()) return; - if (!thesaurus) - thesaurus = agi::util::make_unique(); - auto results = thesaurus->Lookup(currentWord); thesSugs.clear(); diff --git a/aegisub/src/thesaurus.cpp b/aegisub/src/thesaurus.cpp index d43f689f9..fdececbb6 100644 --- a/aegisub/src/thesaurus.cpp +++ b/aegisub/src/thesaurus.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -99,7 +100,17 @@ void Thesaurus::OnLanguageChanged() { LOG_I("thesaurus/file") << "Using thesaurus: " << dat; - impl = agi::util::make_unique(dat, idx); + agi::dispatch::Background().Async([=]{ + try { + auto thes = agi::util::make_unique(dat, idx); + agi::dispatch::Main().Sync([&]{ + impl = std::move(thes); + }); + } + catch (agi::Exception const& e) { + LOG_E("thesaurus") << e.GetChainedMessage(); + } + }); } void Thesaurus::OnPathChanged() { diff --git a/aegisub/src/thesaurus.h b/aegisub/src/thesaurus.h index 4485c5daa..0383cce45 100644 --- a/aegisub/src/thesaurus.h +++ b/aegisub/src/thesaurus.h @@ -14,11 +14,6 @@ // // Aegisub Project http://www.aegisub.org/ -/// @file thesaurus.h -/// @see thesaurus.cpp -/// @ingroup thesaurus -/// - #include #include #include