Skip to content
Permalink
Browse files

Use the QgsPostgresConnPool interface from column type thread

Avoids using shared connections from multiple threads,
fixing #13141
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Jan 18, 2016
1 parent 433e3b8 commit 4ccb08dbadaca8153f69ddda7ab8b3b79729239b
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/providers/postgres/qgscolumntypethread.cpp
@@ -16,6 +16,7 @@ email : jef at norbit dot de
***************************************************************************/

#include "qgscolumntypethread.h"
#include "qgspostgresconnpool.h"
#include "qgslogger.h"

#include <QMetaType>
@@ -38,13 +39,15 @@ void QgsGeomColumnTypeThread::stop()
return;

mConn->cancel();
QgsPostgresConnPool::instance()->releaseConnection( mConn );
mConn = nullptr;
mStopped = true;
}

void QgsGeomColumnTypeThread::run()
{
QgsDataSourceURI uri = QgsPostgresConn::connUri( mName );
mConn = QgsPostgresConn::connectDb( uri.connectionInfo( false ), true );
mConn = QgsPostgresConnPool::instance()->acquireConnection( uri.connectionInfo( false ) );
if ( !mConn )
{
QgsDebugMsg( "Connection failed - " + uri.connectionInfo( false ) );
@@ -63,7 +66,7 @@ void QgsGeomColumnTypeThread::run()
mAllowGeometrylessTables ) ||
layerProperties.isEmpty() )
{
mConn->unref();
QgsPostgresConnPool::instance()->releaseConnection( mConn );
mConn = nullptr;
return;
}
@@ -109,6 +112,7 @@ void QgsGeomColumnTypeThread::run()
emit progress( 0, 0 );
emit progressMessage( tr( "Table retrieval finished." ) );

mConn->unref();
QgsPostgresConnPool::instance()->releaseConnection( mConn );
//mConn->unref();
mConn = nullptr;
}

0 comments on commit 4ccb08d

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