From 3a9028d7ea6f14cf6039e6aba7606c4d71371338 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Tue, 19 Oct 2010 11:50:26 +1000 Subject: Fix crash on exit. If QNetworkConfigurationManager is deleted from the QApplication destructor it will be deleted after QNetworkConfigurationManagerPrivate global static (which is also deleted by QApplication). Fixed by testing if connManager() returns 0 before use. Task-number: QTBUG-14447 --- src/network/bearer/qnetworkconfigmanager.cpp | 38 ++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/network/bearer/qnetworkconfigmanager.cpp b/src/network/bearer/qnetworkconfigmanager.cpp index 23d7800..4c149a2 100644 --- a/src/network/bearer/qnetworkconfigmanager.cpp +++ b/src/network/bearer/qnetworkconfigmanager.cpp @@ -229,8 +229,8 @@ QNetworkConfigurationManager::QNetworkConfigurationManager( QObject* parent ) QNetworkConfigurationManager::~QNetworkConfigurationManager() { QNetworkConfigurationManagerPrivate *priv = connManager(); - - priv->disablePolling(); + if (priv) + priv->disablePolling(); } @@ -245,7 +245,11 @@ QNetworkConfigurationManager::~QNetworkConfigurationManager() */ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const { - return connManager()->defaultConfiguration(); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + return priv->defaultConfiguration(); + + return QNetworkConfiguration(); } /*! @@ -275,7 +279,11 @@ QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const */ QList QNetworkConfigurationManager::allConfigurations(QNetworkConfiguration::StateFlags filter) const { - return connManager()->allConfigurations(filter); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + return priv->allConfigurations(filter); + + return QList(); } /*! @@ -286,7 +294,11 @@ QList QNetworkConfigurationManager::allConfigurations(QNe */ QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString &identifier) const { - return connManager()->configurationFromIdentifier(identifier); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + return priv->configurationFromIdentifier(identifier); + + return QNetworkConfiguration(); } /*! @@ -301,7 +313,11 @@ QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier( */ bool QNetworkConfigurationManager::isOnline() const { - return connManager()->isOnline(); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + return priv->isOnline(); + + return false; } /*! @@ -309,7 +325,11 @@ bool QNetworkConfigurationManager::isOnline() const */ QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const { - return connManager()->capabilities(); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + return priv->capabilities(); + + return QNetworkConfigurationManager::Capabilities(0); } /*! @@ -328,7 +348,9 @@ QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabil */ void QNetworkConfigurationManager::updateConfigurations() { - connManager()->performAsyncConfigurationUpdate(); + QNetworkConfigurationManagerPrivate *priv = connManager(); + if (priv) + priv->performAsyncConfigurationUpdate(); } #include "moc_qnetworkconfigmanager.cpp" -- cgit v0.12