mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Fix crash in change language box.
Each time a radiobutton was triggered it was destroyed in refresh().
This commit is contained in:
parent
a5e0b19b79
commit
10906e2e16
1 changed files with 4 additions and 2 deletions
|
@ -54,6 +54,7 @@ LanguageBox::Inner::Inner(QWidget *parent, gsl::not_null<Languages*> languages)
|
|||
_group->setChangedCallback([this](int value) { languageChanged(value); });
|
||||
subscribe(Lang::Current().updated(), [this] {
|
||||
activateCurrent();
|
||||
refresh();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -96,12 +97,13 @@ void LanguageBox::Inner::languageChanged(int languageIndex) {
|
|||
void LanguageBox::Inner::activateCurrent() {
|
||||
auto currentId = Lang::Current().id();
|
||||
for (auto i = 0, count = _languages->size(); i != count; ++i) {
|
||||
if ((*_languages)[i].id == currentId) {
|
||||
auto languageId = (*_languages)[i].id;
|
||||
auto isCurrent = (languageId == currentId) || (languageId == Lang::DefaultLanguageId() && currentId.isEmpty());
|
||||
if (isCurrent) {
|
||||
_group->setValue(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
refresh();
|
||||
}
|
||||
|
||||
void LanguageBox::prepare() {
|
||||
|
|
Loading…
Add table
Reference in a new issue