[locale] Move more business logic to Config

- writing *localeConf* settings to GS can be done always when the
  formats are set, rather than special-cased. The code
  that handles the "special case" of no widget existing for the ViewStep
  overlooks the other crashes that happen then.
- Since Config knows what jobs to create, just ask it rather than
  keeping a copy.
This commit is contained in:
Adriaan de Groot 2020-07-22 00:23:50 +02:00
parent f6419d5de1
commit 0c9480aa3f
3 changed files with 12 additions and 22 deletions

View File

@ -170,18 +170,28 @@ Config::Config( QObject* parent )
connect( this, &Config::currentLocationChanged, [&]() {
auto* gs = Calamares::JobQueue::instance()->globalStorage();
// Update the GS region and zone (and possibly the live timezone)
const auto* location = currentLocation();
bool locationChanged = ( location->region() != gs->value( "locationRegion" ) )
|| ( location->zone() != gs->value( "locationZone" ) );
gs->insert( "locationRegion", location->region() );
gs->insert( "locationZone", location->zone() );
if ( locationChanged && m_adjustLiveTimezone )
{
QProcess::execute( "timedatectl", // depends on systemd
{ "set-timezone", location->region() + '/' + location->zone() } );
}
// Update GS localeConf (the LC_ variables)
auto map = localeConfiguration().toMap();
QVariantMap vm;
for ( auto it = map.constBegin(); it != map.constEnd(); ++it )
{
vm.insert( it.key(), it.value() );
}
gs->insert( "localeConf", vm );
} );
}

View File

@ -147,7 +147,7 @@ LocaleViewStep::isAtEnd() const
Calamares::JobList
LocaleViewStep::jobs() const
{
return m_jobs;
return m_config->createJobs();
}
@ -165,24 +165,6 @@ LocaleViewStep::onActivate()
void
LocaleViewStep::onLeave()
{
if ( m_actualWidget )
{
m_jobs = m_config->createJobs();
auto map = m_config->localeConfiguration().toMap();
QVariantMap vm;
for ( auto it = map.constBegin(); it != map.constEnd(); ++it )
{
vm.insert( it.key(), it.value() );
}
Calamares::JobQueue::instance()->globalStorage()->insert( "localeConf", vm );
}
else
{
m_jobs.clear();
Calamares::JobQueue::instance()->globalStorage()->remove( "localeConf" );
}
}

View File

@ -71,8 +71,6 @@ private:
LocalePage* m_actualWidget;
bool m_nextEnabled;
Calamares::JobList m_jobs;
CalamaresUtils::GeoIP::RegionZonePair m_startingTimezone;
std::unique_ptr< CalamaresUtils::GeoIP::Handler > m_geoip;