Skip to content
Permalink
Browse files

fix : allow copying style from an unavailable layer

(cherry picked from commit 2bcb63e)
  • Loading branch information
olivierdalang authored and nyalldawson committed Jun 9, 2020
1 parent a2b06f4 commit baf892645c13f1c5a4b33ea4b996ca3e324317b6
Showing with 5 additions and 2 deletions.
  1. +1 −1 src/core/qgsmaplayer.cpp
  2. +4 −1 src/core/qgsvectorlayer.cpp
@@ -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;
@@ -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 ) )
{

0 comments on commit baf8926

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