[welcome] Avoid crash when no Branding available

- don't install translators twice -- do it in setLocaleIndex only
- avoid crash if the branding instance is nullptr
This commit is contained in:
Adriaan de Groot 2021-08-24 11:58:24 +02:00
parent 38c65e80f3
commit e9a98f35ad

View File

@ -152,8 +152,6 @@ Config::initLanguages()
{
QString name = m_languages->locale( matchedLocaleIndex ).name();
cDebug() << Logger::SubEntry << "Matched with index" << matchedLocaleIndex << name;
CalamaresUtils::installTranslator( name, Calamares::Branding::instance()->translationsDirectory() );
setLocaleIndex( matchedLocaleIndex );
}
else
@ -192,7 +190,8 @@ Config::setLocaleIndex( int index )
cDebug() << "Index" << index << "Selected locale" << selectedLocale;
QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator( selectedLocale, Calamares::Branding::instance()->translationsDirectory() );
const auto* branding = Calamares::Branding::instance();
CalamaresUtils::installTranslator( selectedLocale, branding ? branding->translationsDirectory() : QString() );
if ( Calamares::JobQueue::instance() && Calamares::JobQueue::instance()->globalStorage() )
{
CalamaresUtils::Locale::insertGS( *Calamares::JobQueue::instance()->globalStorage(),