File tree Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Expand file tree Collapse file tree 4 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 17
17
#include " qgslogger.h"
18
18
#include " qgsmaplayerregistry.h"
19
19
#include " qgsproviderregistry.h"
20
+ #include " qgsnetworkaccessmanager.h"
20
21
#include " qgsexception.h"
21
22
#include " qgsgeometry.h"
22
23
@@ -609,6 +610,8 @@ void QgsApplication::exitQgis()
609
610
delete QgsMapLayerRegistry::instance ();
610
611
611
612
delete QgsProviderRegistry::instance ();
613
+
614
+ delete QgsNetworkAccessManager::instance ();
612
615
}
613
616
614
617
QString QgsApplication::showSettings ()
Original file line number Diff line number Diff line change @@ -86,10 +86,17 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory
86
86
}
87
87
};
88
88
89
- QgsNetworkAccessManager *QgsNetworkAccessManager::instance ()
89
+ //
90
+ // Static calls to enforce singleton behaviour
91
+ //
92
+ QgsNetworkAccessManager* QgsNetworkAccessManager::sInstance = 0 ;
93
+ QgsNetworkAccessManager* QgsNetworkAccessManager::instance ()
90
94
{
91
- static QgsNetworkAccessManager sInstance ;
92
- return &sInstance ;
95
+ if ( sInstance == 0 )
96
+ {
97
+ sInstance = new QgsNetworkAccessManager ();
98
+ }
99
+ return sInstance ;
93
100
}
94
101
95
102
QgsNetworkAccessManager::QgsNetworkAccessManager ( QObject *parent )
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
48
48
public:
49
49
// ! returns a pointer to the single instance
50
50
// and creates that instance on the first call.
51
- static QgsNetworkAccessManager * instance ();
51
+ static QgsNetworkAccessManager* instance ();
52
52
53
53
QgsNetworkAccessManager ( QObject *parent = 0 );
54
54
@@ -100,6 +100,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
100
100
QNetworkProxy mFallbackProxy ;
101
101
QStringList mExcludedURLs ;
102
102
bool mUseSystemProxy ;
103
+ static QgsNetworkAccessManager* sInstance ;
103
104
};
104
105
105
106
#endif // QGSNETWORKACCESSMANAGER_H
Original file line number Diff line number Diff line change 16
16
***************************************************************************/
17
17
18
18
#include " qgsnetworkcontentfetcher.h"
19
+ #include " qgsapplication.h"
19
20
#include < QObject>
20
21
#include < QtTest>
21
22
#include < QNetworkReply>
@@ -44,22 +45,21 @@ class TestQgsNetworkContentFetcher: public QObject
44
45
45
46
void TestQgsNetworkContentFetcher::initTestCase ()
46
47
{
47
-
48
+ QgsApplication::init ();
49
+ QgsApplication::initQgis ();
48
50
}
49
51
50
52
void TestQgsNetworkContentFetcher::cleanupTestCase ()
51
53
{
52
-
54
+ QgsApplication::exitQgis ();
53
55
}
54
56
55
57
void TestQgsNetworkContentFetcher::init ()
56
58
{
57
-
58
59
}
59
60
60
61
void TestQgsNetworkContentFetcher::cleanup ()
61
62
{
62
-
63
63
}
64
64
65
65
void TestQgsNetworkContentFetcher::fetchEmptyUrl ()
You can’t perform that action at this time.
0 commit comments