Skip to content
Permalink
Browse files

Add thread safe QgsNetworkAccessManager::requestTimedOut signal

  • Loading branch information
nyalldawson committed Jan 23, 2019
1 parent 1190000 commit 5824faf6742b39706024e3c146874d44e61bbf2c
@@ -173,6 +173,8 @@ created in any thread.

.. seealso:: :py:func:`finished`

.. seealso:: :py:func:`requestTimedOut`

.. versionadded:: 3.6
%End

@@ -189,6 +191,23 @@ created in any thread.

.. seealso:: :py:func:`requestAboutToBeCreated`

.. seealso:: :py:func:`requestTimedOut`

.. versionadded:: 3.6
%End

void requestTimedOut( QgsNetworkRequestParameters request );
%Docstring
Emitted when a network request has timed out.

This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
only to connect to the main thread's signal in order to receive notifications about requests
created in any thread.

.. seealso:: :py:func:`requestAboutToBeCreated`

.. seealso:: :py:func:`finished`

.. versionadded:: 3.6
%End

@@ -243,8 +243,8 @@ void QgsNetworkAccessManager::abortRequest()
QgsDebugMsgLevel( QStringLiteral( "Abort [reply:%1] %2" ).arg( reinterpret_cast< qint64 >( reply ), 0, 16 ).arg( reply->url().toString() ), 3 );
QgsMessageLog::logMessage( tr( "Network request %1 timed out" ).arg( reply->url().toString() ), tr( "Network" ) );
// Notify the application
emit requestTimedOut( QgsNetworkRequestParameters( reply->operation(), reply->request(), reply->property( "requestId" ).toInt() ) );
emit requestTimedOut( reply );

}

void QgsNetworkAccessManager::onReplyFinished( QNetworkReply *reply )
@@ -308,8 +308,11 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache( Qt::ConnectionType conn
sMainNAM, &QNetworkAccessManager::proxyAuthenticationRequired,
connectionType );

connect( this, &QgsNetworkAccessManager::requestTimedOut,
sMainNAM, &QgsNetworkAccessManager::requestTimedOut );
connect( this, qgis::overload< QNetworkReply *>::of( &QgsNetworkAccessManager::requestTimedOut ),
sMainNAM, qgis::overload< QNetworkReply *>::of( &QgsNetworkAccessManager::requestTimedOut ) );

connect( this, qgis::overload< QgsNetworkRequestParameters >::of( &QgsNetworkAccessManager::requestTimedOut ),
sMainNAM, qgis::overload< QgsNetworkRequestParameters >::of( &QgsNetworkAccessManager::requestTimedOut ) );

connect( this, qgis::overload< QgsNetworkRequestParameters >::of( &QgsNetworkAccessManager::requestAboutToBeCreated ),
sMainNAM, qgis::overload< QgsNetworkRequestParameters >::of( &QgsNetworkAccessManager::requestAboutToBeCreated ) );
@@ -174,6 +174,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
* created in any thread.
*
* \see finished( QgsNetworkReplyContent )
* \see requestTimedOut( QgsNetworkRequestParameters )
* \since QGIS 3.6
*/
void requestAboutToBeCreated( QgsNetworkRequestParameters request );
@@ -189,10 +190,24 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
* created in any thread.
*
* \see requestAboutToBeCreated( QgsNetworkRequestParameters )
* \see requestTimedOut( QgsNetworkRequestParameters )
* \since QGIS 3.6
*/
void finished( QgsNetworkReplyContent reply );

/**
* Emitted when a network request has timed out.
*
* This signal is propagated to the main thread QgsNetworkAccessManager instance, so it is necessary
* only to connect to the main thread's signal in order to receive notifications about requests
* created in any thread.
*
* \see requestAboutToBeCreated( QgsNetworkRequestParameters )
* \see finished( QgsNetworkReplyContent )
* \since QGIS 3.6
*/
void requestTimedOut( QgsNetworkRequestParameters request );

void requestCreated( QNetworkReply * );
void requestTimedOut( QNetworkReply * );

@@ -38,7 +38,7 @@ QgsWfsRequest::QgsWfsRequest( const QgsWFSDataSourceURI &uri )
, mGotNonEmptyResponse( false )
{
QgsDebugMsgLevel( QStringLiteral( "theUri = " ) + uri.uri( ), 4 );
connect( QgsNetworkAccessManager::instance(), &QgsNetworkAccessManager::requestTimedOut, this, &QgsWfsRequest::requestTimedOut );
connect( QgsNetworkAccessManager::instance(), qgis::overload< QNetworkReply *>::of( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsWfsRequest::requestTimedOut );
}

QgsWfsRequest::~QgsWfsRequest()

0 comments on commit 5824faf

Please sign in to comment.
You can’t perform that action at this time.