mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Use direct connection for NAM auth connections
This commit is contained in:
parent
b756a021ca
commit
620d4d7abb
@ -32,7 +32,7 @@ that the fallback proxy should not be used for, then no proxy will be used.
|
||||
#include "qgsnetworkaccessmanager.h"
|
||||
%End
|
||||
public:
|
||||
static QgsNetworkAccessManager *instance();
|
||||
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::DirectConnection );
|
||||
|
||||
QgsNetworkAccessManager( QObject *parent = 0 );
|
||||
|
||||
@ -76,7 +76,7 @@ Gets name for QNetworkRequest.CacheLoadControl
|
||||
Gets QNetworkRequest.CacheLoadControl from name
|
||||
%End
|
||||
|
||||
void setupDefaultProxyAndCache();
|
||||
void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
|
||||
%Docstring
|
||||
Setup the NAM according to the user's settings
|
||||
%End
|
||||
|
@ -102,7 +102,7 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory
|
||||
//
|
||||
// Static calls to enforce singleton behavior
|
||||
//
|
||||
QgsNetworkAccessManager *QgsNetworkAccessManager::instance()
|
||||
QgsNetworkAccessManager *QgsNetworkAccessManager::instance( Qt::ConnectionType connectionType )
|
||||
{
|
||||
static QThreadStorage<QgsNetworkAccessManager> sInstances;
|
||||
QgsNetworkAccessManager *nam = &sInstances.localData();
|
||||
@ -111,7 +111,7 @@ QgsNetworkAccessManager *QgsNetworkAccessManager::instance()
|
||||
sMainNAM = nam;
|
||||
|
||||
if ( !nam->mInitialized )
|
||||
nam->setupDefaultProxyAndCache();
|
||||
nam->setupDefaultProxyAndCache( connectionType );
|
||||
|
||||
return nam;
|
||||
}
|
||||
@ -281,7 +281,7 @@ QNetworkRequest::CacheLoadControl QgsNetworkAccessManager::cacheLoadControlFromN
|
||||
return QNetworkRequest::PreferNetwork;
|
||||
}
|
||||
|
||||
void QgsNetworkAccessManager::setupDefaultProxyAndCache()
|
||||
void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType connectionType )
|
||||
{
|
||||
mInitialized = true;
|
||||
mUseSystemProxy = false;
|
||||
@ -292,11 +292,11 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache()
|
||||
{
|
||||
connect( this, &QNetworkAccessManager::authenticationRequired,
|
||||
sMainNAM, &QNetworkAccessManager::authenticationRequired,
|
||||
Qt::BlockingQueuedConnection );
|
||||
connectionType );
|
||||
|
||||
connect( this, &QNetworkAccessManager::proxyAuthenticationRequired,
|
||||
sMainNAM, &QNetworkAccessManager::proxyAuthenticationRequired,
|
||||
Qt::BlockingQueuedConnection );
|
||||
connectionType );
|
||||
|
||||
connect( this, &QgsNetworkAccessManager::requestTimedOut,
|
||||
sMainNAM, &QgsNetworkAccessManager::requestTimedOut );
|
||||
@ -304,7 +304,7 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache()
|
||||
#ifndef QT_NO_SSL
|
||||
connect( this, &QNetworkAccessManager::sslErrors,
|
||||
sMainNAM, &QNetworkAccessManager::sslErrors,
|
||||
Qt::BlockingQueuedConnection );
|
||||
connectionType );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
|
||||
public:
|
||||
//! returns a pointer to the single instance
|
||||
// and creates that instance on the first call.
|
||||
static QgsNetworkAccessManager *instance();
|
||||
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::DirectConnection );
|
||||
|
||||
QgsNetworkAccessManager( QObject *parent = nullptr );
|
||||
|
||||
@ -80,7 +80,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
|
||||
static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
|
||||
|
||||
//! Setup the NAM according to the user's settings
|
||||
void setupDefaultProxyAndCache();
|
||||
void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
|
||||
|
||||
//! Returns whether the system proxy should be used
|
||||
bool useSystemProxy() const { return mUseSystemProxy; }
|
||||
|
@ -133,6 +133,9 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
|
||||
QMutex mutex;
|
||||
std::function<bool()> downloaderFunction = [ this, request, synchronous, &waitCondition ]()
|
||||
{
|
||||
if ( QThread::currentThread() != QgsApplication::instance()->thread() )
|
||||
QgsNetworkAccessManager::instance( Qt::DirectConnection );
|
||||
|
||||
bool success = true;
|
||||
mReply = QgsNetworkAccessManager::instance()->get( request );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user