Skip to content
Permalink
Browse files

Merge pull request #1314 from manisandro/network_timeout

Restart timeout timer when data is received in QgsNetworkAccessManager
  • Loading branch information
jef-n committed Apr 10, 2014
2 parents a1f1b94 + d2dce59 commit d1dffdc30c561de8164854d25b08ed39709b8f8c
Showing with 17 additions and 0 deletions.
  1. +8 −0 src/app/qgisapp.cpp
  2. +2 −0 src/app/qgisapp.h
  3. +5 −0 src/core/qgsnetworkaccessmanager.cpp
  4. +2 −0 src/core/qgsnetworkaccessmanager.h
@@ -9301,6 +9301,8 @@ void QgisApp::namSetup()
connect( nam, SIGNAL( proxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ),
this, SLOT( namProxyAuthenticationRequired( const QNetworkProxy &, QAuthenticator * ) ) );

connect( nam, SIGNAL( requestTimedOut( QNetworkReply* ) ), this, SLOT( namRequestTimedOut( QNetworkReply* ) ) );

#ifndef QT_NO_OPENSSL
connect( nam, SIGNAL( sslErrors( QNetworkReply *, const QList<QSslError> & ) ),
this, SLOT( namSslErrors( QNetworkReply *, const QList<QSslError> & ) ) );
@@ -9386,6 +9388,12 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
}
#endif

void QgisApp::namRequestTimedOut( QNetworkReply *reply )
{
QgsMessageLog::logMessage( tr( "The request '%1' timed out. Any data received is likely incomplete." ).arg( reply->url().toString() ), QString::null, QgsMessageLog::WARNING );
messageBar()->pushMessage( tr( "Network request timeout" ), tr( "A network request timed out, any data received is likely incomplete." ), QgsMessageBar::WARNING, messageTimeout() );
}

void QgisApp::namUpdate()
{
QgsNetworkAccessManager::instance()->setupDefaultProxyAndCache();
@@ -594,6 +594,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
#ifndef QT_NO_OPENSSL
void namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors );
#endif
void namRequestTimedOut( QNetworkReply *reply );

//! update default action of toolbutton
void toolButtonActionTriggered( QAction * );
@@ -1553,3 +1554,4 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
#endif

#endif

@@ -161,6 +161,8 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
timer->setSingleShot( true );
timer->start( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt() );

connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), timer, SLOT( start() ) );

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Apr 12, 2014

Member

Isn't that already handled in QgsNetworkAccessManager::connectionProgress()?


mActiveRequests.insert( reply, timer );
return reply;
}
@@ -194,6 +196,8 @@ void QgsNetworkAccessManager::abortRequest()

if ( reply->isRunning() )
reply->close();

emit requestTimedOut( reply );
}

QString QgsNetworkAccessManager::cacheLoadControlName( QNetworkRequest::CacheLoadControl theControl )
@@ -324,3 +328,4 @@ void QgsNetworkAccessManager::setupDefaultProxyAndCache()
setProxy( proxy );
#endif
}

@@ -87,6 +87,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
signals:
void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
void requestCreated( QNetworkReply * );
void requestTimedOut( QNetworkReply * );

private slots:
void connectionProgress();
@@ -105,3 +106,4 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
};

#endif // QGSNETWORKACCESSMANAGER_H

0 comments on commit d1dffdc

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