From 6ce84d2c347f49c9aae0c1953e2b2529228db430 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 21 May 2020 10:02:09 +1000 Subject: [PATCH] [layouts] Warn when previewing an atlas and a feature with no geometry 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 --- src/app/layout/qgslayoutdesignerdialog.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp index de9c9c3387c2..60fa7e6d1547 100644 --- a/src/app/layout/qgslayoutdesignerdialog.cpp +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -4458,7 +4458,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()