Skip to content

Commit

Permalink
Also cleared cached legend data on map extent/rotation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 2, 2020
1 parent 4a125f6 commit 33fc5d4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/layout/qgslayoutitemlegend.cpp
Expand Up @@ -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 );
}
Expand All @@ -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 );
}
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions src/core/layout/qgslayoutitemlegend.h
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit 33fc5d4

Please sign in to comment.