Skip to content
Permalink
Browse files
Fix deadlock on joins cache
Fixes #43287

The critical section was called recursively by a call form the model
connected to joinedFieldsChanged.

By moving the mutex into a scope we can safely release it before
emitting the signal.
  • Loading branch information
elpaso authored and nyalldawson committed May 28, 2021
1 parent 32995d5 commit 3b612b05d8777af6a68ec4558f82104ee62356e8
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/core/vector/qgsvectorlayerjoinbuffer.cpp
@@ -100,19 +100,21 @@ bool QgsVectorLayerJoinBuffer::addJoin( const QgsVectorLayerJoinInfo &joinInfo )

bool QgsVectorLayerJoinBuffer::removeJoin( const QString &joinLayerId )
{
QMutexLocker locker( &mMutex );
bool res = false;
for ( int i = 0; i < mVectorJoins.size(); ++i )
{
if ( mVectorJoins.at( i ).joinLayerId() == joinLayerId )
QMutexLocker locker( &mMutex );
for ( int i = 0; i < mVectorJoins.size(); ++i )
{
if ( QgsVectorLayer *vl = mVectorJoins.at( i ).joinLayer() )
if ( mVectorJoins.at( i ).joinLayerId() == joinLayerId )
{
disconnect( vl, &QgsVectorLayer::updatedFields, this, &QgsVectorLayerJoinBuffer::joinedLayerUpdatedFields );
}
if ( QgsVectorLayer *vl = mVectorJoins.at( i ).joinLayer() )
{
disconnect( vl, &QgsVectorLayer::updatedFields, this, &QgsVectorLayerJoinBuffer::joinedLayerUpdatedFields );
}

mVectorJoins.removeAt( i );
res = true;
mVectorJoins.removeAt( i );
res = true;
}
}
}

0 comments on commit 3b612b0

Please sign in to comment.