[libcalamares] Fix network-connectivity check on old Qt

With old Qt, Calamares could only run one check on a thread,
because the NAM would be switched to NotAccessible --
subsequent checks would fail because the NAM is already
hard-set to NotAccessible, so it could never be turned back
on by Calamares code.

Reset the accessible flag for the NAM while checking if
the internet is there.
main
Adriaan de Groot 4 years ago
parent 0851a8a6a4
commit 0aa2603a23

@ -162,6 +162,15 @@ Manager::checkHasInternet()
{ {
return false; return false;
} }
// It's possible that access was switched off (see below, if the check
// fails) so we want to turn it back on first. Otherwise all the
// checks will fail **anyway**, defeating the point of the checks.
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
if ( !d->m_hasInternet )
{
d->nam()->setNetworkAccessible( QNetworkAccessManager::Accessible );
}
#endif
if ( d->m_lastCheckedUrlIndex < 0 ) if ( d->m_lastCheckedUrlIndex < 0 )
{ {
d->m_lastCheckedUrlIndex = 0; d->m_lastCheckedUrlIndex = 0;
@ -189,8 +198,7 @@ Manager::checkHasInternet()
// For earlier Qt versions (< 5.15.0), set the accessibility flag to // For earlier Qt versions (< 5.15.0), set the accessibility flag to
// NotAccessible if synchronous ping has failed, so that any module // NotAccessible if synchronous ping has failed, so that any module
// using Qt's networkAccessible method to determine whether or not // using Qt's networkAccessible method to determine whether or not
// internet connection is actually avaialable won't get confused over // internet connection is actually available won't get confused.
// virtualization technologies.
#if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) ) #if ( QT_VERSION < QT_VERSION_CHECK( 5, 15, 0 ) )
if ( !d->m_hasInternet ) if ( !d->m_hasInternet )
{ {
@ -261,6 +269,7 @@ asynchronousRun( QNetworkAccessManager* nam, const QUrl& url, const RequestOptio
// Bail out early if the request is bad // Bail out early if the request is bad
if ( reply->error() ) if ( reply->error() )
{ {
cWarning() << "Early reply error" << reply->error() << reply->errorString();
reply->deleteLater(); reply->deleteLater();
return nullptr; return nullptr;
} }

Loading…
Cancel
Save