Skip to content
Permalink
Browse files

log network timeouts

  • Loading branch information
jef-n committed Aug 18, 2012
1 parent bb623a8 commit 1e2838f588163a4de5a75494aaadd53187dfd7aa
Showing with 19 additions and 1 deletion.
  1. +16 −1 src/core/qgsnetworkaccessmanager.cpp
  2. +3 −0 src/core/qgsnetworkaccessmanager.h
@@ -20,6 +20,7 @@
***************************************************************************/

#include <qgsnetworkaccessmanager.h>
#include <qgsmessagelog.h>
#include <qgslogger.h>

#include <QUrl>
@@ -132,9 +133,23 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op

// abort request, when network timeout happens
QTimer *timer = new QTimer( reply );
connect( timer, SIGNAL( timeout() ), this, SLOT( abortRequest() ) );

QSettings s;
timer->singleShot( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt(), reply, SLOT( abort() ) );
timer->start( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt() );

return reply;
}

void QgsNetworkAccessManager::abortRequest()
{
QTimer *timer = qobject_cast<QTimer *>( sender() );
Q_ASSERT( timer );

QNetworkReply *reply = qobject_cast<QNetworkReply *>( timer->parent() );
Q_ASSERT( reply );

QgsMessageLog::logMessage( tr( "Network request %1 timed out" ).arg( reply->url().toString() ), tr( "Network" ) );

reply->abort();
}
@@ -76,6 +76,9 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
void requestAboutToBeCreated( QNetworkAccessManager::Operation, const QNetworkRequest &, QIODevice * );
void requestCreated( QNetworkReply * );

private slots:
void abortRequest();

protected:
virtual QNetworkReply *createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest & req, QIODevice * outgoingData = 0 );

0 comments on commit 1e2838f

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