@@ -131,6 +131,7 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
131131
132132 QWaitCondition waitCondition;
133133 QMutex waitConditionMutex;
134+
134135 bool threadFinished = false ;
135136 bool success = false ;
136137
@@ -163,20 +164,20 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
163164 {
164165 auto resumeMainThread = [&waitConditionMutex, &waitCondition]()
165166 {
167+ // when this method is called we have "produced" a single authentication request -- so the buffer is now full
168+ // and it's time for the "consumer" (main thread) to do its part
166169 waitConditionMutex.lock ();
167170 waitCondition.wakeAll ();
168171 waitConditionMutex.unlock ();
169172
170- waitConditionMutex.lock ();
171- waitCondition.wait ( &waitConditionMutex );
172- waitConditionMutex.unlock ();
173+ // note that we don't need to handle waking this thread back up - that's done automatically by QgsNetworkAccessManager
173174 };
174175
175- connect ( QgsNetworkAccessManager::instance (), &QgsNetworkAccessManager::authenticationRequired , this , resumeMainThread, Qt::DirectConnection );
176+ connect ( QgsNetworkAccessManager::instance (), &QgsNetworkAccessManager::authRequestOccurred , this , resumeMainThread, Qt::DirectConnection );
176177 connect ( QgsNetworkAccessManager::instance (), &QgsNetworkAccessManager::proxyAuthenticationRequired, this , resumeMainThread, Qt::DirectConnection );
177178
178179#ifndef QT_NO_SSL
179- connect ( QgsNetworkAccessManager::instance (), &QgsNetworkAccessManager::sslErrors , this , resumeMainThread, Qt::DirectConnection );
180+ connect ( QgsNetworkAccessManager::instance (), &QgsNetworkAccessManager::sslErrorsOccurred , this , resumeMainThread, Qt::DirectConnection );
180181#endif
181182 QEventLoop loop;
182183 connect ( this , &QgsWfsRequest::downloadFinished, &loop, &QEventLoop::quit, Qt::DirectConnection );
@@ -205,17 +206,16 @@ bool QgsWfsRequest::sendGET( const QUrl &url, bool synchronous, bool forceRefres
205206 waitCondition.wait ( &waitConditionMutex );
206207
207208 // If the downloader thread wakes us (the main thread) up and is not yet finished
208- // he needs the authentication to run .
209+ // then it has "produced" an authentication request which we need to now "consume" .
209210 // The processEvents() call gives the auth manager the chance to show a dialog and
210211 // once done with that, we can wake the downloaderThread again and continue the download.
211212 if ( !threadFinished )
212213 {
213214 waitConditionMutex.unlock ();
214215
215216 QgsApplication::instance ()->processEvents ();
216- waitConditionMutex.lock ();
217- waitCondition.wakeAll ();
218- waitConditionMutex.unlock ();
217+ // we don't need to wake up the worker thread - it will automatically be woken when
218+ // the auth request has been dealt with by QgsNetworkAccessManager
219219 }
220220 else
221221 {
0 commit comments