Skip to content
Permalink
Browse files

don't restart network timeout timer twice (followup a63de6d, partly r…

…everts d7c29ae)
  • Loading branch information
jef-n committed Apr 12, 2014
1 parent 16414cb commit 235795baafd388b1d848a1e91e771b36b8fc43dd
Showing with 1 addition and 27 deletions.
  1. +1 −21 src/core/qgsnetworkaccessmanager.cpp
  2. +0 −6 src/core/qgsnetworkaccessmanager.h
@@ -150,9 +150,6 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
emit requestAboutToBeCreated( op, req, outgoingData );
QNetworkReply *reply = QNetworkAccessManager::createRequest( op, req, outgoingData );

connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( connectionProgress() ) );
connect( reply, SIGNAL( uploadProgress( qint64, qint64 ) ), this, SLOT( connectionProgress() ) );
connect( reply, SIGNAL( destroyed( QObject* ) ), this, SLOT( connectionDestroyed( QObject* ) ) );
emit requestCreated( reply );

// abort request, when network timeout happens
@@ -162,28 +159,11 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
timer->start( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt() );

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

mActiveRequests.insert( reply, timer );
return reply;
}

void QgsNetworkAccessManager::connectionProgress()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>( sender() );
Q_ASSERT( reply );

QTimer* timer = mActiveRequests.find( reply ).value();
Q_ASSERT( timer );

QSettings s;
timer->start( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt() );
}

void QgsNetworkAccessManager::connectionDestroyed( QObject* reply )
{
mActiveRequests.remove( static_cast<QNetworkReply*>( reply ) );
}

void QgsNetworkAccessManager::abortRequest()
{
QTimer *timer = qobject_cast<QTimer *>( sender() );
@@ -24,8 +24,6 @@
#include <QNetworkProxy>
#include <QNetworkRequest>

class QTimer;

/*
* \class QgsNetworkAccessManager
* \brief network access manager for QGIS
@@ -90,8 +88,6 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
void requestTimedOut( QNetworkReply * );

private slots:
void connectionProgress();
void connectionDestroyed( QObject* );
void abortRequest();

protected:
@@ -101,8 +97,6 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
QList<QNetworkProxyFactory*> mProxyFactories;
QNetworkProxy mFallbackProxy;
QStringList mExcludedURLs;

QMap<QNetworkReply*, QTimer*> mActiveRequests;
};

#endif // QGSNETWORKACCESSMANAGER_H

0 comments on commit 235795b

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