Skip to content

Commit cec7e48

Browse files
committedApr 4, 2023
Fix layout legend layer title not immediately updating
Fixes #52261
1 parent 0d8b2fb commit cec7e48

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed
 

‎python/core/auto_generated/layout/qgslayoutitemlegend.sip.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ Returns the legend's renderer settings object.
593593

594594
virtual void refresh();
595595

596+
virtual void invalidateCache();
597+
596598
virtual void refreshDataDefinedProperty( QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties );
597599

598600

‎src/core/layout/qgslayoutitemlegend.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ void QgsLayoutItemLegend::refresh()
194194
onAtlasFeature();
195195
}
196196

197+
void QgsLayoutItemLegend::invalidateCache()
198+
{
199+
clearLegendCachedData();
200+
QgsLayoutItem::invalidateCache();
201+
}
202+
197203
void QgsLayoutItemLegend::draw( QgsLayoutItemRenderContext &context )
198204
{
199205
QPainter *painter = context.renderContext().painter();

‎src/core/layout/qgslayoutitemlegend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem
560560
public slots:
561561

562562
void refresh() override;
563+
void invalidateCache() override;
563564
void refreshDataDefinedProperty( QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::AllProperties ) override;
564565

565566
protected:

‎src/gui/layout/qgslayoutlegendwidget.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,6 +1695,7 @@ void QgsLayoutLegendNodeWidget::labelChanged()
16951695
}
16961696

16971697
mLegend->adjustBoxSize();
1698+
mLegend->invalidateCache();
16981699
mLegend->update();
16991700
mLegend->endCommand();
17001701
}

0 commit comments

Comments
 (0)
Please sign in to comment.