Skip to content
Permalink
Browse files
Restart timeout timer when data is received in QgsNetworkAccessManage…
…r, show a message if timeout is reached.
  • Loading branch information
manisandro committed Apr 9, 2014
1 parent 5f19830 commit a63de6d4b18011e16f9f7d2f009ff1d9509dd957
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
@@ -9296,6 +9296,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> & ) ) );
@@ -9381,6 +9383,11 @@ void QgisApp::namSslErrors( QNetworkReply *reply, const QList<QSslError> &errors
}
#endif

void QgisApp::namRequestTimedOut( QNetworkReply *reply )
{
QMessageBox::warning( this, tr( "Network request timed out" ), tr( "The following request timed out %1. If any data was received, it is likely incomplete." ).arg( reply->url().toString() ) );
}

void QgisApp::namUpdate()
{
QgsNetworkAccessManager::instance()->setupDefaultProxyAndCache();
@@ -9560,3 +9567,4 @@ LONG WINAPI QgisApp::qgisCrashDump( struct _EXCEPTION_POINTERS *ExceptionInfo )
return EXCEPTION_EXECUTE_HANDLER;
}
#endif

@@ -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() ) );

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 a63de6d

Please sign in to comment.