[welcome] Only do GeoIP query if it's useful

- If badly-configured, then type is none; this is warned about
   in the constructor of Handler()
 - Only run the query if it's a useful type.
This commit is contained in:
Adriaan de Groot 2019-06-18 12:34:52 +02:00
parent 68dc1f5e31
commit 0f66a89236

View File

@ -128,16 +128,24 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
CalamaresUtils::getString( geoip, "style" ), CalamaresUtils::getString( geoip, "style" ),
CalamaresUtils::getString( geoip, "url" ), CalamaresUtils::getString( geoip, "url" ),
CalamaresUtils::getString( geoip, "selector" ) ); CalamaresUtils::getString( geoip, "selector" ) );
auto* future = new FWString(); if ( handler->type() != CalamaresUtils::GeoIP::Handler::Type::None )
connect( future, &FWString::finished, [view=this, f=future, h=handler]()
{ {
QString countryResult = f->future().result(); auto* future = new FWString();
cDebug() << "GeoIP result for welcome=" << countryResult; connect( future, &FWString::finished, [view=this, f=future, h=handler]()
view->setCountry( countryResult, h ); {
f->deleteLater(); QString countryResult = f->future().result();
delete h; cDebug() << "GeoIP result for welcome=" << countryResult;
} ); view->setCountry( countryResult, h );
future->setFuture( handler->queryRaw() ); f->deleteLater();
delete h;
} );
future->setFuture( handler->queryRaw() );
}
else
{
// Would not produce useful country code anyway.
delete handler;
}
} }