Skip to content

Commit

Permalink
Fix deadlock on joins cache
Browse files Browse the repository at this point in the history
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 3b612b0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/core/vector/qgsvectorlayerjoinbuffer.cpp
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit 3b612b0

Please sign in to comment.