Skip to content

Commit

Permalink
Only use threaded legend hit test for preview renders
Browse files Browse the repository at this point in the history
In other cases we'll need a blocking hit test anyway, and we
run a risk of deadlocks if a non-preview render is then started
on the main thread.

Fixes #58496
  • Loading branch information
nyalldawson authored and troopa81 committed Oct 4, 2024
1 parent 4ed54c1 commit 007f224
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/core/layout/qgslayoutitemlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,6 @@ void QgsLayoutItemLegend::paint( QPainter *painter, const QStyleOptionGraphicsIt
doUpdateFilterByMap();
}

if ( mLayout )
{
if ( !mLayout->renderContext().isPreviewRender() && mLegendModel->hitTestInProgress() )
{
mLegendModel->waitForHitTestBlocking();
}
}

const int dpi = painter->device()->logicalDpiX();
const double dotsPerMM = dpi / 25.4;

Expand Down Expand Up @@ -1128,6 +1120,10 @@ void QgsLayoutItemLegend::doUpdateFilterByMap()
mLegendModel->setLayerStyleOverrides( QMap<QString, QString>() );
}

// only use thread hit tests for preview renders. In other cases we'll need a blocking hit test anyway, and we run a risk
// of deadlocks if a non-preview render is then started on the main thread.
mLegendModel->setFlag( QgsLayerTreeModel::UseThreadedHitTest, mLayout->renderContext().isPreviewRender() );

const bool filterByExpression = QgsLayerTreeUtils::hasLegendFilterExpression( *( mCustomLayerTree ? mCustomLayerTree.get() : mLayout->project()->layerTreeRoot() ) );

const bool hasValidFilter = filterByExpression
Expand Down

0 comments on commit 007f224

Please sign in to comment.