Skip to content
Permalink
Browse files

[bugfix] Crash when exporting (invalid) legend to qlr

Fixes #18981 Save QLR crashes QGIS 3

This patch definitely prevents the crash but I'm not sure if
we should also introduce the same check in QgsLayerTree::isLayer
or even in QgsLayerTreeGroup::findLayers() or also when importing
a qlr that might lead to invalid layer (like in this
bug report).
  • Loading branch information
elpaso committed Jun 6, 2018
1 parent 8ef0d1f commit ec909b0aabb9ed66050130672b19af1c9c1f5338
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/core/qgslayerdefinition.cpp
@@ -214,6 +214,11 @@ bool QgsLayerDefinition::exportLayerDefinition( QDomDocument doc, const QList<Qg
QList<QgsLayerTreeLayer *> layers = root->findLayers();
Q_FOREACH ( QgsLayerTreeLayer *layer, layers )
{
if ( ! layer->layer() )
{
QgsDebugMsgLevel( QStringLiteral( "Not a valid map layer: skipping %1" ).arg( layer->name( ) ), 4 );
continue;
}
QDomElement layerelm = doc.createElement( QStringLiteral( "maplayer" ) );
layer->layer()->writeLayerXml( layerelm, doc, context );
layerselm.appendChild( layerelm );

0 comments on commit ec909b0

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