Skip to content
Permalink
Browse files

If vector layer renderer cannot be loaded, fallback to default

Eg if loading a project which used a plugin based renderer which
is not available, qgis would not renderer the layer and
eventually crash. Now if the saved renderer could not be
restored we fallback to a default renderer for the layer.
  • Loading branch information
nyalldawson committed Sep 4, 2016
1 parent 95c4fa1 commit 96e10ebff20f633a2a476eec088a3be354c73862
Showing with 19 additions and 8 deletions.
  1. +19 −8 src/core/qgsvectorlayer.cpp
@@ -1786,6 +1786,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage

bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage )
{
bool result = true;
emit readCustomSymbology( node.toElement(), errorMessage );

if ( hasGeometryType() )
@@ -1795,18 +1796,28 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage )
if ( !rendererElement.isNull() )
{
QgsFeatureRenderer* r = QgsFeatureRenderer::load( rendererElement );
if ( !r )
return false;

setRenderer( r );
if ( r )
{
setRenderer( r );
}
else
{
result = false;
}
}
else
{
QgsFeatureRenderer* r = QgsSymbologyConversion::readOldRenderer( node, geometryType() );
if ( !r )
r = QgsFeatureRenderer::defaultRenderer( geometryType() );
if ( r )
{
setRenderer( r );
}
}

setRenderer( r );
// make sure layer has a renderer - if none exists, fallback to a default renderer
if ( !renderer() )
{
setRenderer( QgsFeatureRenderer::defaultRenderer( geometryType() ) );
}

QDomElement labelingElement = node.firstChildElement( "labeling" );
@@ -1879,7 +1890,7 @@ bool QgsVectorLayer::readStyle( const QDomNode &node, QString &errorMessage )
}
}
}
return true;
return result;
}

bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const

0 comments on commit 96e10eb

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