Skip to content
Permalink
Browse files

Fix occasional crash on exit because of statis network access manager

  • Loading branch information
m-kuhn committed Nov 8, 2014
1 parent f3eeed9 commit 95f880a570b3b54fae8f1b649ddeb4ecf3564760
@@ -17,6 +17,7 @@
#include "qgslogger.h"
#include "qgsmaplayerregistry.h"
#include "qgsproviderregistry.h"
#include "qgsnetworkaccessmanager.h"
#include "qgsexception.h"
#include "qgsgeometry.h"

@@ -609,6 +610,8 @@ void QgsApplication::exitQgis()
delete QgsMapLayerRegistry::instance();

delete QgsProviderRegistry::instance();

delete QgsNetworkAccessManager::instance();
}

QString QgsApplication::showSettings()
@@ -86,10 +86,17 @@ class QgsNetworkProxyFactory : public QNetworkProxyFactory
}
};

QgsNetworkAccessManager *QgsNetworkAccessManager::instance()
//
// Static calls to enforce singleton behaviour
//
QgsNetworkAccessManager* QgsNetworkAccessManager::sInstance = 0;
QgsNetworkAccessManager* QgsNetworkAccessManager::instance()
{
static QgsNetworkAccessManager sInstance;
return &sInstance;
if ( sInstance == 0 )
{
sInstance = new QgsNetworkAccessManager();
}
return sInstance;
}

QgsNetworkAccessManager::QgsNetworkAccessManager( QObject *parent )
@@ -48,7 +48,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
public:
//! returns a pointer to the single instance
// and creates that instance on the first call.
static QgsNetworkAccessManager *instance();
static QgsNetworkAccessManager* instance();

QgsNetworkAccessManager( QObject *parent = 0 );

@@ -100,6 +100,7 @@ class CORE_EXPORT QgsNetworkAccessManager : public QNetworkAccessManager
QNetworkProxy mFallbackProxy;
QStringList mExcludedURLs;
bool mUseSystemProxy;
static QgsNetworkAccessManager* sInstance;
};

#endif // QGSNETWORKACCESSMANAGER_H
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgsnetworkcontentfetcher.h"
#include "qgsapplication.h"
#include <QObject>
#include <QtTest>
#include <QNetworkReply>
@@ -44,22 +45,21 @@ class TestQgsNetworkContentFetcher: public QObject

void TestQgsNetworkContentFetcher::initTestCase()
{

QgsApplication::init();
QgsApplication::initQgis();
}

void TestQgsNetworkContentFetcher::cleanupTestCase()
{

QgsApplication::exitQgis();
}

void TestQgsNetworkContentFetcher::init()
{

}

void TestQgsNetworkContentFetcher::cleanup()
{

}

void TestQgsNetworkContentFetcher::fetchEmptyUrl()

0 comments on commit 95f880a

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