Navigation Menu

Skip to content

Commit

Permalink
make initialization of connection pool thread save on MSVC
Browse files Browse the repository at this point in the history
(probably better fix for 1e96813)
  • Loading branch information
jef-n committed May 31, 2015
1 parent 6a84e07 commit c550af2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrconnpool.cpp
Expand Up @@ -15,10 +15,10 @@

#include "qgsogrconnpool.h"

QgsOgrConnPool QgsOgrConnPool::sInstance;

QgsOgrConnPool* QgsOgrConnPool::instance()
{
static QgsOgrConnPool sInstance;
return &sInstance;
}

Expand Down
2 changes: 2 additions & 0 deletions src/providers/ogr/qgsogrconnpool.h
Expand Up @@ -85,6 +85,8 @@ class QgsOgrConnPool : public QgsConnectionPool<QgsOgrConn*, QgsOgrConnPoolGroup
private:
QgsOgrConnPool();
~QgsOgrConnPool();

static QgsOgrConnPool sInstance;
};


Expand Down
14 changes: 2 additions & 12 deletions src/providers/postgres/qgspostgresconnpool.cpp
Expand Up @@ -16,21 +16,11 @@
#include "qgspostgresconnpool.h"
#include "qgspostgresconn.h"

QgsPostgresConnPool QgsPostgresConnPool::sInstance;

QgsPostgresConnPool* QgsPostgresConnPool::instance()
{
static QgsPostgresConnPool *sInstance = 0;

if ( !sInstance )
{
static QMutex m;
m.lock();
if ( !sInstance )
sInstance = new QgsPostgresConnPool();
m.unlock();
}

return sInstance;
return &sInstance;
}

QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool<QgsPostgresConn*, QgsPostgresConnPoolGroup>()
Expand Down
3 changes: 2 additions & 1 deletion src/providers/postgres/qgspostgresconnpool.h
Expand Up @@ -17,7 +17,6 @@
#define QGSPOSTGRESCONNPOOL_H

#include "qgsconnectionpool.h"

#include "qgspostgresconn.h"


Expand Down Expand Up @@ -77,6 +76,8 @@ class QgsPostgresConnPool : public QgsConnectionPool<QgsPostgresConn*, QgsPostgr
private:
QgsPostgresConnPool();
~QgsPostgresConnPool();

static QgsPostgresConnPool sInstance;
};


Expand Down
2 changes: 1 addition & 1 deletion src/providers/spatialite/qgsspatialiteconnpool.cpp
Expand Up @@ -15,9 +15,9 @@

#include "qgsspatialiteconnpool.h"

QgsSpatiaLiteConnPool QgsSpatiaLiteConnPool::sInstance;

QgsSpatiaLiteConnPool* QgsSpatiaLiteConnPool::instance()
{
static QgsSpatiaLiteConnPool sInstance;
return &sInstance;
}
3 changes: 1 addition & 2 deletions src/providers/spatialite/qgsspatialiteconnpool.h
Expand Up @@ -17,7 +17,6 @@
#define QGSSPATIALITECONPOOL_H

#include "qgsconnectionpool.h"

#include "qgsspatialiteconnection.h"

inline QString qgsConnectionPool_ConnectionToName( QgsSqliteHandle* c )
Expand Down Expand Up @@ -67,9 +66,9 @@ class QgsSpatiaLiteConnPoolGroup : public QObject, public QgsConnectionPoolGroup
/** SpatiaLite connection pool - singleton */
class QgsSpatiaLiteConnPool : public QgsConnectionPool<QgsSqliteHandle*, QgsSpatiaLiteConnPoolGroup>
{
static QgsSpatiaLiteConnPool sInstance;
public:
static QgsSpatiaLiteConnPool* instance();

};


Expand Down

0 comments on commit c550af2

Please sign in to comment.