Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix crash on exit: delete postgres connection pool before QApplication
  • Loading branch information
m-kuhn committed Apr 12, 2016
1 parent 601e430 commit 9a161ac
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/providers/postgres/qgspostgresconnpool.cpp
Expand Up @@ -16,11 +16,19 @@
#include "qgspostgresconnpool.h"
#include "qgspostgresconn.h"

QgsPostgresConnPool QgsPostgresConnPool::sInstance;
QgsPostgresConnPool* QgsPostgresConnPool::sInstance = nullptr;

QgsPostgresConnPool* QgsPostgresConnPool::instance()
{
return &sInstance;
if ( !sInstance )
sInstance = new QgsPostgresConnPool();
return sInstance;
}

void QgsPostgresConnPool::cleanupInstance()
{
delete sInstance;
sInstance = nullptr;
}

QgsPostgresConnPool::QgsPostgresConnPool() : QgsConnectionPool<QgsPostgresConn*, QgsPostgresConnPoolGroup>()
Expand Down
4 changes: 3 additions & 1 deletion src/providers/postgres/qgspostgresconnpool.h
Expand Up @@ -70,14 +70,16 @@ class QgsPostgresConnPool : public QgsConnectionPool<QgsPostgresConn*, QgsPostgr
public:
static QgsPostgresConnPool* instance();

static void cleanupInstance();

protected:
Q_DISABLE_COPY( QgsPostgresConnPool )

private:
QgsPostgresConnPool();
~QgsPostgresConnPool();

static QgsPostgresConnPool sInstance;
static QgsPostgresConnPool* sInstance;
};


Expand Down
4 changes: 4 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -4130,6 +4130,10 @@ QGISEXTERN QgsTransaction* createTransaction( const QString& connString )
return new QgsPostgresTransaction( connString );
}

QGISEXTERN void cleanupProvider()
{
QgsPostgresConnPool::cleanupInstance();
}

// ----------

Expand Down

0 comments on commit 9a161ac

Please sign in to comment.