forked from mia/Aegisub
Delay creation of the thesaurus until it's needed
Although in absolute terms it does not take very long, loading the 18 MB en_US thesaurus was about three quarters of Aegisub's total startup time when opening with no command line arguments. Originally committed to SVN as r6702.
This commit is contained in:
parent
20a31f8e32
commit
e5540de2da
1 changed files with 6 additions and 3 deletions
|
@ -82,7 +82,6 @@ enum {
|
||||||
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context)
|
SubsTextEditCtrl::SubsTextEditCtrl(wxWindow* parent, wxSize wsize, long style, agi::Context *context)
|
||||||
: ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style)
|
: ScintillaTextCtrl(parent, -1, "", wxDefaultPosition, wsize, style)
|
||||||
, spellchecker(SpellCheckerFactory::GetSpellChecker())
|
, spellchecker(SpellCheckerFactory::GetSpellChecker())
|
||||||
, thesaurus(new Thesaurus)
|
|
||||||
, context(context)
|
, context(context)
|
||||||
{
|
{
|
||||||
// Set properties
|
// Set properties
|
||||||
|
@ -738,7 +737,6 @@ void SubsTextEditCtrl::OnContextMenu(wxContextMenuEvent &event) {
|
||||||
if (!currentWord.empty()) {
|
if (!currentWord.empty()) {
|
||||||
if (spellchecker)
|
if (spellchecker)
|
||||||
AddSpellCheckerEntries(menu);
|
AddSpellCheckerEntries(menu);
|
||||||
if (thesaurus)
|
|
||||||
AddThesaurusEntries(menu);
|
AddThesaurusEntries(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,6 +790,9 @@ void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
|
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) {
|
||||||
|
if (!thesaurus)
|
||||||
|
thesaurus.reset(new Thesaurus);
|
||||||
|
|
||||||
std::vector<Thesaurus::Entry> result;
|
std::vector<Thesaurus::Entry> result;
|
||||||
thesaurus->Lookup(currentWord, &result);
|
thesaurus->Lookup(currentWord, &result);
|
||||||
|
|
||||||
|
@ -915,6 +916,8 @@ void SubsTextEditCtrl::OnSetDicLanguage(wxCommandEvent &event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubsTextEditCtrl::OnSetThesLanguage(wxCommandEvent &event) {
|
void SubsTextEditCtrl::OnSetThesLanguage(wxCommandEvent &event) {
|
||||||
|
if (!thesaurus) return;
|
||||||
|
|
||||||
wxArrayString langs = thesaurus->GetLanguageList();
|
wxArrayString langs = thesaurus->GetLanguageList();
|
||||||
|
|
||||||
int index = event.GetId() - EDIT_MENU_THES_LANGS - 1;
|
int index = event.GetId() - EDIT_MENU_THES_LANGS - 1;
|
||||||
|
|
Loading…
Reference in a new issue