From 4200b85fb49f43168941d717a3cd325bd8c6c4a3 Mon Sep 17 00:00:00 2001 From: scx Date: Sun, 1 Sep 2019 23:40:47 +0200 Subject: [PATCH] Fix crashing when picking language Aegisub crashes immediately after selecting any language from the end of the list (above the 100th position). This is because it can support no more than 100 languages. This patch extends this limit up to 1000 languages (locales). Fixes Aegisub/Aegisub#131 --- src/subs_edit_ctrl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/subs_edit_ctrl.cpp b/src/subs_edit_ctrl.cpp index 1a87c147c..d41cd24d0 100644 --- a/src/subs_edit_ctrl.cpp +++ b/src/subs_edit_ctrl.cpp @@ -56,6 +56,10 @@ #include #include +// Maximum number of languages (locales) +// It should be above 100 (at least 242) and probably not more than 1000 +#define LANGS_MAX 1000 + /// Event ids enum { EDIT_MENU_SPLIT_PRESERVE = 1400, @@ -73,7 +77,7 @@ enum { EDIT_MENU_THESAURUS_SUGS, EDIT_MENU_DIC_LANGUAGE = 1600, EDIT_MENU_DIC_LANGS, - EDIT_MENU_THES_LANGUAGE = 1700, + EDIT_MENU_THES_LANGUAGE = EDIT_MENU_DIC_LANGUAGE + LANGS_MAX, EDIT_MENU_THES_LANGS }; @@ -196,7 +200,7 @@ BEGIN_EVENT_TABLE(SubsTextEditCtrl,wxStyledTextCtrl) EVT_MENU_RANGE(EDIT_MENU_SUGGESTIONS,EDIT_MENU_THESAURUS-1,SubsTextEditCtrl::OnUseSuggestion) EVT_MENU_RANGE(EDIT_MENU_THESAURUS_SUGS,EDIT_MENU_DIC_LANGUAGE-1,SubsTextEditCtrl::OnUseSuggestion) EVT_MENU_RANGE(EDIT_MENU_DIC_LANGS,EDIT_MENU_THES_LANGUAGE-1,SubsTextEditCtrl::OnSetDicLanguage) - EVT_MENU_RANGE(EDIT_MENU_THES_LANGS,EDIT_MENU_THES_LANGS+100,SubsTextEditCtrl::OnSetThesLanguage) + EVT_MENU_RANGE(EDIT_MENU_THES_LANGS,EDIT_MENU_THES_LANGS+LANGS_MAX,SubsTextEditCtrl::OnSetThesLanguage) END_EVENT_TABLE() void SubsTextEditCtrl::OnLoseFocus(wxFocusEvent &event) {