Skip to content

Commit

Permalink
force not shared postgres connection on non main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed May 30, 2017
1 parent a468abb commit 0f26431
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/providers/postgres/qgspostgresconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado
QMap<QString, QgsPostgresConn *> &connections =
readonly ? QgsPostgresConn::sConnectionsRO : QgsPostgresConn::sConnectionsRW;

// This is called from may places where shared parameter cannot be forced to false (QgsVectorLayerExporter)
// and which is run in a different thread (drag and drop in browser)
if ( QApplication::instance()->thread() != QThread::currentThread() )
{
shared = false;
}

if ( shared )
{
// sharing connection between threads is not safe
Expand Down

0 comments on commit 0f26431

Please sign in to comment.