summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-29 22:17:21 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-07-29 22:17:21 (GMT)
commit597a842d66dc04181bfd063863216acbb11ce3bc (patch)
treef8597dc11d4e4cf34af9ef782152bca9be8d14cd /examples
parent12e5d8897fbd60def1dd38608c1cd3f0d1d4317b (diff)
downloadQt-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.cpp24
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);