Skip to content

Commit 0f26431

Browse files
committed
force not shared postgres connection on non main thread
1 parent a468abb commit 0f26431

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/providers/postgres/qgspostgresconn.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ QgsPostgresConn *QgsPostgresConn::connectDb( const QString &conninfo, bool reado
146146
QMap<QString, QgsPostgresConn *> &connections =
147147
readonly ? QgsPostgresConn::sConnectionsRO : QgsPostgresConn::sConnectionsRW;
148148

149+
// This is called from may places where shared parameter cannot be forced to false (QgsVectorLayerExporter)
150+
// and which is run in a different thread (drag and drop in browser)
151+
if ( QApplication::instance()->thread() != QThread::currentThread() )
152+
{
153+
shared = false;
154+
}
155+
149156
if ( shared )
150157
{
151158
// sharing connection between threads is not safe

0 commit comments

Comments
 (0)