Skip to content

Commit ff499bc

Browse files
author
jef
committed
instantiate proxy factory only once
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13272 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent da9278c commit ff499bc

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

src/app/qgisapp.cpp

+8-15
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
359359
, mSplash( splash )
360360
, mPythonUtils( NULL )
361361
, mNAM( NULL )
362+
, mProxyFactory( NULL )
362363
, mpTileScaleWidget( NULL )
363364
#ifdef HAVE_QWT
364365
, mpGpsWidget( NULL )
@@ -972,26 +973,12 @@ void QgisApp::createActions()
972973
mActionAddPgLayer = new QAction( getThemeIcon( "mActionAddLayer.png" ), tr( "Add PostGIS Layer..." ), this );
973974
shortcuts->registerAction( mActionAddPgLayer, tr( "Ctrl+Shift+D", "Add a PostGIS Layer" ) );
974975
mActionAddPgLayer->setStatusTip( tr( "Add a PostGIS Layer" ) );
975-
//#ifdef HAVE_POSTGRESQL
976-
// QgsDebugMsg("HAVE_POSTGRESQL is defined");
977-
// assert(0);
978-
//#else
979-
// QgsDebugMsg("HAVE_POSTGRESQL not defined");
980-
// assert(0);
981-
//#endif
982976
connect( mActionAddPgLayer, SIGNAL( triggered() ), this, SLOT( addDatabaseLayer() ) );
983977

984978
mActionAddSpatiaLiteLayer = new QAction( getThemeIcon( "mActionAddSpatiaLiteLayer.png" ), tr( "Add SpatiaLite Layer..." ), this );
985979
shortcuts->registerAction( mActionAddSpatiaLiteLayer, tr( "Ctrl+Shift+L", "Add a SpatiaLite Layer" ) );
986980
mActionAddSpatiaLiteLayer->setStatusTip( tr( "Add a SpatiaLite Layer" ) );
987981
connect( mActionAddSpatiaLiteLayer, SIGNAL( triggered() ), this, SLOT( addSpatiaLiteLayer() ) );
988-
//#ifdef HAVE_SPATIALITE
989-
// QgsDebugMsg("HAVE_SPATIALITE is defined");
990-
// assert(0);
991-
//#else
992-
// QgsDebugMsg("HAVE_SPATIALITE not defined");
993-
// assert(0);
994-
//#endif
995982

996983
mActionAddWmsLayer = new QAction( getThemeIcon( "mActionAddWmsLayer.png" ), tr( "Add WMS Layer..." ), this );
997984
shortcuts->registerAction( mActionAddWmsLayer, tr( "Ctrl+Shift+W", "Add a Web Mapping Server Layer" ) );
@@ -6724,7 +6711,13 @@ void QgisApp::namUpdate()
67246711
}
67256712

67266713
#if QT_VERSION >= 0x40500
6727-
mNAM->setProxyFactory( new QgsNetworkProxyFactory( proxy, excludes ) );
6714+
if( !mProxyFactory )
6715+
{
6716+
mProxyFactory = new QgsNetworkProxyFactory();
6717+
mNAM->setProxyFactory( mProxyFactory );
6718+
}
6719+
6720+
mProxyFactory->setProxyAndExcludes( proxy, excludes );
67286721

67296722
QNetworkDiskCache *cache = qobject_cast<QNetworkDiskCache*>( nam()->cache() );
67306723
if ( !cache )

src/app/qgisapp.h

+7
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ class QgsGPSInformationWidget;
8080
#include "qgsfeature.h"
8181
#include "qgspoint.h"
8282

83+
#if QT_VERSION >= 0x40500
84+
class QgsNetworkProxyFactory;
85+
#endif
86+
8387
/*! \class QgisApp
8488
* \brief Main window for the Qgis application
8589
*/
@@ -1090,6 +1094,9 @@ class QgisApp : public QMainWindow
10901094
QgsUndoWidget* mUndoWidget;
10911095

10921096
QNetworkAccessManager *mNAM;
1097+
#if QT_VERSION >= 0x40500
1098+
QgsNetworkProxyFactory *mProxyFactory;
1099+
#endif
10931100

10941101
int mLastComposerId;
10951102

src/app/qgsnetworkproxyfactory.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@
2626
#include "qgsnetworkproxyfactory.h"
2727
#include "qgslogger.h"
2828

29-
QgsNetworkProxyFactory::QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes )
29+
QgsNetworkProxyFactory::QgsNetworkProxyFactory()
30+
{
31+
}
32+
33+
void QgsNetworkProxyFactory::setProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes )
3034
{
3135
mProxy = proxy;
3236
mExcludedURLs = excludes;

src/app/qgsnetworkproxyfactory.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
2626
class QgsNetworkProxyFactory : public QNetworkProxyFactory
2727
{
2828
public:
29-
QgsNetworkProxyFactory( const QNetworkProxy &proxy, const QStringList &excludes );
29+
QgsNetworkProxyFactory();
3030
virtual ~QgsNetworkProxyFactory();
3131
virtual QList<QNetworkProxy> queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );
3232

33+
void setProxyAndExcludes( const QNetworkProxy &proxy, const QStringList &excludes );
34+
3335
private:
3436
QStringList mExcludedURLs;
3537
QNetworkProxy mProxy;

0 commit comments

Comments
 (0)