Skip to content
Permalink
Browse files

Also cleared cached legend data on map extent/rotation changes

  • Loading branch information
nyalldawson committed Jun 1, 2020
1 parent 4a125f6 commit 33fc5d42713621a95fd65335bd243c4d6b89bbae
Showing with 5 additions and 3 deletions.
  1. +3 −0 src/core/layout/qgslayoutitemlegend.cpp
  2. +2 −3 src/core/layout/qgslayoutitemlegend.h
@@ -695,6 +695,7 @@ void QgsLayoutItemLegend::setupMapConnections( QgsLayoutItemMap *map, bool conne
disconnect( map, &QObject::destroyed, this, &QgsLayoutItemLegend::invalidateCurrentMap );
disconnect( map, &QgsLayoutObject::changed, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
disconnect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
disconnect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
disconnect( map, &QgsLayoutItemMap::layerStyleOverridesChanged, this, &QgsLayoutItemLegend::mapLayerStyleOverridesChanged );
disconnect( map, &QgsLayoutItemMap::themeChanged, this, &QgsLayoutItemLegend::mapThemeChanged );
}
@@ -703,6 +704,7 @@ void QgsLayoutItemLegend::setupMapConnections( QgsLayoutItemMap *map, bool conne
connect( map, &QObject::destroyed, this, &QgsLayoutItemLegend::invalidateCurrentMap );
connect( map, &QgsLayoutObject::changed, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
connect( map, &QgsLayoutItemMap::extentChanged, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
connect( map, &QgsLayoutItemMap::mapRotationChanged, this, &QgsLayoutItemLegend::updateFilterByMapAndRedraw );
connect( map, &QgsLayoutItemMap::layerStyleOverridesChanged, this, &QgsLayoutItemLegend::mapLayerStyleOverridesChanged );
connect( map, &QgsLayoutItemMap::themeChanged, this, &QgsLayoutItemLegend::mapThemeChanged );
}
@@ -862,6 +864,7 @@ void QgsLayoutItemLegend::updateFilterByMap( bool redraw )
// the actual update will take place before the redraw.
// This is to avoid multiple calls to the filter
mFilterAskedForUpdate = true;
clearLegendCachedData();

if ( redraw )
update();
@@ -550,6 +550,8 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem

void nodeCustomPropertyChanged( QgsLayerTreeNode *node, const QString &key );

//! Clears any data cached for the legend model
void clearLegendCachedData();

private:
QgsLayoutItemLegend() = delete;
@@ -561,9 +563,6 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem

void setModelStyleOverrides( const QMap<QString, QString> &overrides );

//! Clears any data cached for the legend model
void clearLegendCachedData();

std::unique_ptr< QgsLegendModel > mLegendModel;
std::unique_ptr< QgsLayerTreeGroup > mCustomLayerTree;

0 comments on commit 33fc5d4

Please sign in to comment.
You can’t perform that action at this time.