Avoid warnings of network information backend showing in CLI
Lazy-initialize the network information backend so warnings it possibly shows don't disturb the output of the CLI (which does not need the network information backend anyway).
This commit is contained in:
parent
1e9d9274cb
commit
f2210a5691
|
@ -114,6 +114,9 @@ SyncthingConnection::SyncthingConnection(
|
|||
, m_recordFileChanges(false)
|
||||
, m_useDeprecatedRoutes(true)
|
||||
, m_pausingOnMeteredConnection(false)
|
||||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
, m_handlingMeteredConnectionInitialized(false)
|
||||
#endif
|
||||
{
|
||||
m_trafficPollTimer.setInterval(SyncthingConnectionSettings::defaultTrafficPollInterval);
|
||||
m_trafficPollTimer.setTimerType(Qt::VeryCoarseTimer);
|
||||
|
@ -135,14 +138,6 @@ SyncthingConnection::SyncthingConnection(
|
|||
setupTestData();
|
||||
#endif
|
||||
|
||||
// initialize handling of metered connections
|
||||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
QNetworkInformation::loadBackendByFeatures(QNetworkInformation::Feature::Metered);
|
||||
if (const auto *const networkInformation = QNetworkInformation::instance()) {
|
||||
QObject::connect(networkInformation, &QNetworkInformation::isMeteredChanged, this, &SyncthingConnection::handleMeteredConnection);
|
||||
}
|
||||
#endif
|
||||
|
||||
setLoggingFlags(loggingFlags);
|
||||
|
||||
// allow initializing the default value for m_useDeprecatedRoutes via environment variable
|
||||
|
@ -268,7 +263,17 @@ void SyncthingConnection::disablePolling()
|
|||
void SyncthingConnection::setPausingOnMeteredConnection(bool pausingOnMeteredConnection)
|
||||
{
|
||||
if (m_pausingOnMeteredConnection != pausingOnMeteredConnection) {
|
||||
m_pausingOnMeteredConnection = pausingOnMeteredConnection;
|
||||
if ((m_pausingOnMeteredConnection = pausingOnMeteredConnection)) {
|
||||
// initialize handling of metered connections
|
||||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
if (!m_handlingMeteredConnectionInitialized) {
|
||||
QNetworkInformation::loadBackendByFeatures(QNetworkInformation::Feature::Metered);
|
||||
if (const auto *const networkInformation = QNetworkInformation::instance()) {
|
||||
QObject::connect(networkInformation, &QNetworkInformation::isMeteredChanged, this, &SyncthingConnection::handleMeteredConnection);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (m_hasConfig) {
|
||||
handleMeteredConnection();
|
||||
}
|
||||
|
|
|
@ -444,6 +444,9 @@ private:
|
|||
bool m_recordFileChanges;
|
||||
bool m_useDeprecatedRoutes;
|
||||
bool m_pausingOnMeteredConnection;
|
||||
#ifdef SYNCTHINGCONNECTION_SUPPORT_METERED
|
||||
bool m_handlingMeteredConnectionInitialized;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*!
|
||||
|
|
Loading…
Reference in New Issue