Slightly delay background render of layout maps in preview

Avoids incurring the main thread preparation cost many times when resizing a layout window
This commit is contained in:
Nyall Dawson 2025-06-24 12:41:17 +10:00 committed by github-actions[bot]
parent eabfb8a96d
commit d9d503a024

View File

@ -1135,13 +1135,13 @@ void QgsLayoutItemMap::paint( QPainter *painter, const QStyleOptionGraphicsItem
{ {
// current job was invalidated - start a new one // current job was invalidated - start a new one
mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter ); mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter );
mBackgroundUpdateTimer->start( 1 ); mBackgroundUpdateTimer->start( 100 );
} }
else if ( !mPainterJob && !mDrawingPreview ) else if ( !mPainterJob && !mDrawingPreview )
{ {
// this is the map's very first paint - trigger a cache update // this is the map's very first paint - trigger a cache update
mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter ); mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter );
mBackgroundUpdateTimer->start( 1 ); mBackgroundUpdateTimer->start( 100 );
} }
renderInProgress = true; renderInProgress = true;
} }
@ -1151,7 +1151,7 @@ void QgsLayoutItemMap::paint( QPainter *painter, const QStyleOptionGraphicsItem
{ {
// cache was invalidated - trigger a background update // cache was invalidated - trigger a background update
mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter ); mPreviewScaleFactor = QgsLayoutUtils::scaleFactorFromItemStyle( style, painter );
mBackgroundUpdateTimer->start( 1 ); mBackgroundUpdateTimer->start( 100 );
renderInProgress = true; renderInProgress = true;
} }