From 10906e2e162a5294dcc5cde155a3708fbd374872 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 18 Jul 2017 20:09:48 +0300 Subject: [PATCH] Fix crash in change language box. Each time a radiobutton was triggered it was destroyed in refresh(). --- Telegram/SourceFiles/boxes/language_box.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/boxes/language_box.cpp b/Telegram/SourceFiles/boxes/language_box.cpp index 7a084ed26..084b4dc07 100644 --- a/Telegram/SourceFiles/boxes/language_box.cpp +++ b/Telegram/SourceFiles/boxes/language_box.cpp @@ -54,6 +54,7 @@ LanguageBox::Inner::Inner(QWidget *parent, gsl::not_null 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() {