Skip to content

Commit

Permalink
Use the QgsPostgresConnPool interface from column type thread
Browse files Browse the repository at this point in the history
Avoids using shared connections from multiple threads,
fixing #13141
  • Loading branch information
Sandro Santilli committed Jan 18, 2016
1 parent 433e3b8 commit 4ccb08d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/providers/postgres/qgscolumntypethread.cpp
Expand Up @@ -16,6 +16,7 @@ email : jef at norbit dot de
***************************************************************************/

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

#include <QMetaType>
Expand All @@ -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 ) );
Expand All @@ -63,7 +66,7 @@ void QgsGeomColumnTypeThread::run()
mAllowGeometrylessTables ) ||
layerProperties.isEmpty() )
{
mConn->unref();
QgsPostgresConnPool::instance()->releaseConnection( mConn );
mConn = nullptr;
return;
}
Expand Down Expand Up @@ -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.