Skip to content

Commit

Permalink
fix : allow copying style from an unavailable layer
Browse files Browse the repository at this point in the history
(cherry picked from commit 2bcb63e)
  • Loading branch information
olivierdalang authored and nyalldawson committed Jun 19, 2020
1 parent a2b06f4 commit baf8926
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsmaplayer.cpp
Expand Up @@ -1056,7 +1056,7 @@ bool QgsMapLayer::importNamedStyle( QDomDocument &myDocument, QString &myErrorMe
{
QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( this );
QgsWkbTypes::GeometryType importLayerGeometryType = static_cast<QgsWkbTypes::GeometryType>( myRoot.firstChildElement( QStringLiteral( "layerGeometryType" ) ).text().toInt() );
if ( vl->geometryType() != importLayerGeometryType )
if ( importLayerGeometryType != QgsWkbTypes::GeometryType::UnknownGeometry && vl->geometryType() != importLayerGeometryType )
{
myErrorMessage = tr( "Cannot apply style with symbology to layer with a different geometry type" );
return false;
Expand Down
5 changes: 4 additions & 1 deletion src/core/qgsvectorlayer.cpp
Expand Up @@ -2621,7 +2621,10 @@ bool QgsVectorLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &err

emit writeCustomSymbology( mapLayerNode, doc, errorMessage );

if ( isSpatial() )
// we must try to write the renderer if our geometry type is unknown
// as this allows the renderer to be correctly restored even for layers
// with broken sources
if ( isSpatial() || mWkbType == QgsWkbTypes::Unknown )
{
if ( categories.testFlag( Symbology ) )
{
Expand Down

0 comments on commit baf8926

Please sign in to comment.