Skip to content

Commit

Permalink
[layouts] Warn when previewing an atlas and a feature with no geometry
Browse files Browse the repository at this point in the history
is encountered, when one or more maps are set to be driven by atlas feature

This situation is definetly not what the user is expecting -- so we
show a warning to them to advise them that the feature has no geometry.

Fixes #36556

(cherry picked from commit 6ce84d2)
  • Loading branch information
nyalldawson committed Jun 19, 2020
1 parent f52652b commit c12c1eb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -4374,7 +4374,24 @@ void QgsLayoutDesignerDialog::atlasFeatureChanged( const QgsFeature &feature )
mapCanvas->stopRendering();
mapCanvas->redrawAllLayers();

mView->setSectionLabel( atlas->nameForPage( atlas->currentFeatureNumber() ) );
const QString atlasFeatureName = atlas->nameForPage( atlas->currentFeatureNumber() );
mView->setSectionLabel( atlasFeatureName );

if ( !feature.hasGeometry() || feature.geometry().isEmpty() )
{
// a little sanity check -- if there's any maps in this layout which are set to be atlas controlled,
// and we hit a feature with no geometry attached, then warn the user
QList< QgsLayoutItemMap * > maps;
mLayout->layoutItems( maps );
for ( const QgsLayoutItemMap *map : qgis::as_const( maps ) )
{
if ( map->atlasDriven() )
{
mMessageBar->pushWarning( QString(), tr( "Atlas feature %1 has no geometry — linked map extents cannot be updated" ).arg( atlasFeatureName ) );
break;
}
}
}
}

void QgsLayoutDesignerDialog::loadPredefinedScalesFromProject()
Expand Down

0 comments on commit c12c1eb

Please sign in to comment.