@@ -49,9 +49,26 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
49
49
Q_OBJECT
50
50
51
51
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 );
55
72
56
73
QgsNetworkAccessManager ( QObject *parent = nullptr );
57
74
@@ -79,7 +96,13 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
79
96
// ! Gets QNetworkRequest::CacheLoadControl from name
80
97
static QNetworkRequest::CacheLoadControl cacheLoadControlFromName ( const QString &name );
81
98
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
+ */
83
106
void setupDefaultProxyAndCache ( Qt::ConnectionType connectionType = Qt::BlockingQueuedConnection );
84
107
85
108
// ! Returns whether the system proxy should be used
0 commit comments