Skip to content

Commit 44e8f60

Browse files
committed
Add documentation
1 parent 620d4d7 commit 44e8f60

File tree

2 files changed

+52
-6
lines changed

2 files changed

+52
-6
lines changed

python/core/auto_generated/qgsnetworkaccessmanager.sip.in

+25-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,26 @@ that the fallback proxy should not be used for, then no proxy will be used.
3232
#include "qgsnetworkaccessmanager.h"
3333
%End
3434
public:
35-
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::DirectConnection );
35+
36+
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
37+
%Docstring
38+
Returns a pointer to the active QgsNetworkAccessManager
39+
for the current thread.
40+
41+
With the ``connectionType`` parameter it is possible to setup the default connection
42+
type that is used to handle signals that might require user interaction and therefore
43+
need to be handled on the main thread. See in-depth discussion below.
44+
45+
:param connectionType: In most cases the default of using a ``Qt.BlockingQueuedConnection``
46+
is ok, to make a background thread wait for the main thread to answer such a request is
47+
fine and anything else is dangerous.
48+
However, in case the request was started on the main thread, one should execute a
49+
local event loop in a helper thread and freeze the main thread for the duration of the
50+
download. In this case, if an authentication request is sent from the background thread
51+
network access manager, the background thread should be blocked, the main thread be woken
52+
up, processEvents() executed once, the main thread frozen again and the background thread
53+
continued.
54+
%End
3655

3756
QgsNetworkAccessManager( QObject *parent = 0 );
3857

@@ -78,7 +97,11 @@ Gets QNetworkRequest.CacheLoadControl from name
7897

7998
void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
8099
%Docstring
81-
Setup the NAM according to the user's settings
100+
Setup the QgsNetworkAccessManager (NAM) according to the user's settings.
101+
The ``connectionType`` sets up the default connection type that is used to
102+
handle signals that might require user interaction and therefore
103+
need to be handled on the main thread. See in-depth discussion in the documentation
104+
for the constructor of this class.
82105
%End
83106

84107
bool useSystemProxy() const;

src/core/qgsnetworkaccessmanager.h

+27-4
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,26 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
4949
Q_OBJECT
5050

5151
public:
52-
//! returns a pointer to the single instance
53-
// and creates that instance on the first call.
54-
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::DirectConnection );
52+
53+
/**
54+
* Returns a pointer to the active QgsNetworkAccessManager
55+
* for the current thread.
56+
*
57+
* With the \a connectionType parameter it is possible to setup the default connection
58+
* type that is used to handle signals that might require user interaction and therefore
59+
* need to be handled on the main thread. See in-depth discussion below.
60+
*
61+
* \param connectionType In most cases the default of using a ``Qt::BlockingQueuedConnection``
62+
* is ok, to make a background thread wait for the main thread to answer such a request is
63+
* fine and anything else is dangerous.
64+
* However, in case the request was started on the main thread, one should execute a
65+
* local event loop in a helper thread and freeze the main thread for the duration of the
66+
* download. In this case, if an authentication request is sent from the background thread
67+
* network access manager, the background thread should be blocked, the main thread be woken
68+
* up, processEvents() executed once, the main thread frozen again and the background thread
69+
* continued.
70+
*/
71+
static QgsNetworkAccessManager *instance( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
5572

5673
QgsNetworkAccessManager( QObject *parent = nullptr );
5774

@@ -79,7 +96,13 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
7996
//! Gets QNetworkRequest::CacheLoadControl from name
8097
static QNetworkRequest::CacheLoadControl cacheLoadControlFromName( const QString &name );
8198

82-
//! Setup the NAM according to the user's settings
99+
/**
100+
* Setup the QgsNetworkAccessManager (NAM) according to the user's settings.
101+
* The \a connectionType sets up the default connection type that is used to
102+
* handle signals that might require user interaction and therefore
103+
* need to be handled on the main thread. See in-depth discussion in the documentation
104+
* for the constructor of this class.
105+
*/
83106
void setupDefaultProxyAndCache( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
84107

85108
//! Returns whether the system proxy should be used

0 commit comments

Comments
 (0)