From 07a723c6ae132e7e8300d185b718be14a3c6c72d Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sat, 29 Aug 2020 12:36:07 +0300 Subject: [PATCH] UI: Check QTranslator::load() result. --- src/ui/translationmanager.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ui/translationmanager.cpp b/src/ui/translationmanager.cpp index 0df3a740..36992746 100644 --- a/src/ui/translationmanager.cpp +++ b/src/ui/translationmanager.cpp @@ -119,6 +119,7 @@ void TranslationManager::installTranslator(int language, const QLocale &locale) QTranslator *translator = m_translators.at(language); if (!translator) { translator = loadTranslator(language, locale); + m_translators.replace(language, translator); } if (translator) { QCoreApplication::installTranslator(translator); @@ -132,9 +133,10 @@ QTranslator *TranslationManager::loadTranslator(int language, const QLocale &loc // Load .qm file auto translator = new QTranslator(this); - translator->load(TRANSLATION_FILE_PREFIX + locale.name(), i18nDir()); - - m_translators.replace(language, translator); + if (!translator->load(TRANSLATION_FILE_PREFIX + locale.name(), i18nDir())) { + delete translator; + return nullptr; + } return translator; }