diff options
author | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-29 22:17:21 (GMT) |
---|---|---|
committer | Aaron McCarthy <aaron.mccarthy@nokia.com> | 2010-07-29 22:17:21 (GMT) |
commit | 597a842d66dc04181bfd063863216acbb11ce3bc (patch) | |
tree | f8597dc11d4e4cf34af9ef782152bca9be8d14cd /examples | |
parent | 12e5d8897fbd60def1dd38608c1cd3f0d1d4317b (diff) | |
download | Qt-597a842d66dc04181bfd063863216acbb11ce3bc.zip Qt-597a842d66dc04181bfd063863216acbb11ce3bc.tar.gz Qt-597a842d66dc04181bfd063863216acbb11ce3bc.tar.bz2 |
Fix crash on Desktop platforms.
Missing check for null networkSession.
Task-number: QTBUG-12501
Diffstat (limited to 'examples')
-rw-r--r-- | examples/network/fortuneserver/server.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp index b931b96..4dca38c 100644 --- a/examples/network/fortuneserver/server.cpp +++ b/examples/network/fortuneserver/server.cpp @@ -107,17 +107,19 @@ Server::Server(QWidget *parent) void Server::sessionOpened() { // Save the used configuration - QNetworkConfiguration config = networkSession->configuration(); - QString id; - if (config.type() == QNetworkConfiguration::UserChoice) - id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); - else - id = config.identifier(); - - QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); - settings.beginGroup(QLatin1String("QtNetwork")); - settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); - settings.endGroup(); + if (networkSession) { + QNetworkConfiguration config = networkSession->configuration(); + QString id; + if (config.type() == QNetworkConfiguration::UserChoice) + id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); + else + id = config.identifier(); + + QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); + settings.beginGroup(QLatin1String("QtNetwork")); + settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); + settings.endGroup(); + } //! [0] //! [1] tcpServer = new QTcpServer(this); |