Skip to content

Commit

Permalink
When temporal range changes we must invalidate the previous labeling
Browse files Browse the repository at this point in the history
solution if any time-enabled vector layers have labels enabled

Fixes #45160
  • Loading branch information
nyalldawson committed Feb 1, 2022
1 parent e0e611e commit d61cab2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Expand Up @@ -888,35 +888,61 @@ void QgsMapCanvas::clearTemporalCache()
{
if ( mCache )
{
bool invalidateLabels = false;
const QList<QgsMapLayer *> layerList = mapSettings().layers();
for ( QgsMapLayer *layer : layerList )
{
if ( layer->temporalProperties() && layer->temporalProperties()->isActive() )
{
if ( QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer ) )
{
if ( vl->labelsEnabled() || vl->diagramsEnabled() )
invalidateLabels = true;
}

if ( layer->temporalProperties()->flags() & QgsTemporalProperty::FlagDontInvalidateCachedRendersWhenRangeChanges )
continue;

mCache->invalidateCacheForLayer( layer );
}
}

if ( invalidateLabels )
{
mCache->clearCacheImage( QStringLiteral( "_labels_" ) );
mCache->clearCacheImage( QStringLiteral( "_preview_labels_" ) );
}
}
}

void QgsMapCanvas::clearElevationCache()
{
if ( mCache )
{
bool invalidateLabels = false;
const QList<QgsMapLayer *> layerList = mapSettings().layers();
for ( QgsMapLayer *layer : layerList )
{
if ( layer->elevationProperties() && layer->elevationProperties()->hasElevation() )
{
if ( QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( layer ) )
{
if ( vl->labelsEnabled() || vl->diagramsEnabled() )
invalidateLabels = true;
}

if ( layer->elevationProperties()->flags() & QgsMapLayerElevationProperties::FlagDontInvalidateCachedRendersWhenRangeChanges )
continue;

mCache->invalidateCacheForLayer( layer );
}
}

if ( invalidateLabels )
{
mCache->clearCacheImage( QStringLiteral( "_labels_" ) );
mCache->clearCacheImage( QStringLiteral( "_preview_labels_" ) );
}
}
}

Expand Down

0 comments on commit d61cab2

Please sign in to comment.