summaryrefslogtreecommitdiffstats
path: root/src/network/access/qnetworkaccessmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/access/qnetworkaccessmanager.cpp')
-rw-r--r--src/network/access/qnetworkaccessmanager.cpp42
1 files changed, 9 insertions, 33 deletions
diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp
index 27b7945..8f050d4 100644
--- a/src/network/access/qnetworkaccessmanager.cpp
+++ b/src/network/access/qnetworkaccessmanager.cpp
@@ -48,6 +48,7 @@
#include "qabstractnetworkcache.h"
#include "QtNetwork/qnetworksession.h"
+#include "QtNetwork/private/qsharednetworksession_p.h"
#include "qnetworkaccesshttpbackend_p.h"
#include "qnetworkaccessftpbackend_p.h"
@@ -1343,11 +1344,8 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
initializeSession = false;
- if (networkSession)
- delete networkSession;
-
if (!config.isValid()) {
- networkSession = 0;
+ networkSession.clear();
online = false;
if (networkAccessible == QNetworkAccessManager::NotAccessible)
@@ -1358,18 +1356,12 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co
return;
}
- networkSession = new QNetworkSession(config, q);
+ networkSession = QSharedNetworkSessionManager::getSession(config);
- QObject::connect(networkSession, SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
- QObject::connect(networkSession, SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
- QObject::connect(networkSession, SIGNAL(stateChanged(QNetworkSession::State)),
+ QObject::connect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
+ QObject::connect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
+ QObject::connect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)),
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));
- QObject::connect(networkSession, SIGNAL(newConfigurationActivated()),
- q, SLOT(_q_networkSessionNewConfigurationActivated()));
- QObject::connect(networkSession,
- SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
- q,
- SLOT(_q_networkSessionPreferredConfigurationChanged(QNetworkConfiguration,bool)));
_q_networkSessionStateChanged(networkSession->state());
}
@@ -1379,32 +1371,16 @@ void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
if (networkSession) {
networkConfiguration = networkSession->configuration().identifier();
- networkSession->deleteLater();
- networkSession = 0;
- }
-}
-
-void QNetworkAccessManagerPrivate::_q_networkSessionNewConfigurationActivated()
-{
- Q_Q(QNetworkAccessManager);
-
- if (networkSession) {
- networkSession->accept();
-
- emit q->networkSessionConnected();
+ networkSession.clear();
}
}
-void QNetworkAccessManagerPrivate::_q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &, bool)
-{
- if (networkSession)
- networkSession->migrate();
-}
-
void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state)
{
Q_Q(QNetworkAccessManager);
+ if (state == QNetworkSession::Connected)
+ emit q->networkSessionConnected();
if (online) {
if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) {
online = false;