Skip to content

Commit

Permalink
Fix #10127 (crash on parallel rendering of spatialite layers)
Browse files Browse the repository at this point in the history
There was a run condition in connection pool singleton: at the beginning,
the singleton got initialized twice. Now the singleton is handled
as a static function variable which should be initialized in thread-safe way.
  • Loading branch information
wonder-sk committed Apr 28, 2014
1 parent 483ba9e commit dd739ef
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/providers/postgres/qgspostgresconnpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@

#include "qgspostgresconn.h"

QgsPostgresConnPool* QgsPostgresConnPool::mInstance = 0;


QgsPostgresConnPool* QgsPostgresConnPool::instance()
{
if ( !mInstance )
mInstance = new QgsPostgresConnPool;
return mInstance;
static QgsPostgresConnPool sInstance;
return &sInstance;
}
2 changes: 0 additions & 2 deletions src/providers/postgres/qgspostgresconnpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ class QgsPostgresConnPool : public QgsConnectionPool<QgsPostgresConn*, QgsPostgr
public:
static QgsPostgresConnPool* instance();

protected:
static QgsPostgresConnPool* mInstance;
};


Expand Down
7 changes: 2 additions & 5 deletions src/providers/spatialite/qgsspatialiteconnpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@

#include "qgsspatialiteconnpool.h"

QgsSpatiaLiteConnPool* QgsSpatiaLiteConnPool::mInstance = 0;


QgsSpatiaLiteConnPool* QgsSpatiaLiteConnPool::instance()
{
if ( !mInstance )
mInstance = new QgsSpatiaLiteConnPool;
return mInstance;
static QgsSpatiaLiteConnPool sInstance;
return &sInstance;
}
2 changes: 0 additions & 2 deletions src/providers/spatialite/qgsspatialiteconnpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class QgsSpatiaLiteConnPool : public QgsConnectionPool<QgsSqliteHandle*, QgsSpat
public:
static QgsSpatiaLiteConnPool* instance();

protected:
static QgsSpatiaLiteConnPool* mInstance;
};


Expand Down

0 comments on commit dd739ef

Please sign in to comment.