Skip to content

Commit

Permalink
Ensure layer metadata is cloned when a layer is cloned
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 10, 2021
1 parent 5954e16 commit 750a68f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -132,6 +132,7 @@ void QgsMapLayer::clone( QgsMapLayer *layer ) const
layer->setCrs( crs() );
layer->setCustomProperties( mCustomProperties );
layer->setOpacity( mLayerOpacity );
layer->setMetadata( mMetadata );
}

QgsMapLayerType QgsMapLayer::type() const
Expand Down
7 changes: 7 additions & 0 deletions tests/src/python/test_qgsvectorlayer.py
Expand Up @@ -59,6 +59,7 @@
QgsTextFormat,
QgsVectorLayerSelectedFeatureSource,
QgsExpression,
QgsLayerMetadata,
NULL)
from qgis.gui import (QgsAttributeTableModel,
QgsGui
Expand Down Expand Up @@ -3029,9 +3030,15 @@ def testClone(self):
action = QgsAction(QgsAction.Unix, "MyActionDescription", "MyActionCmd")
layer.actions().addAction(action)

metadata = QgsLayerMetadata()
metadata.setFees('a handful of roos')
layer.setMetadata(metadata)

# clone layer
clone = layer.clone()

self.assertEqual(layer.metadata().fees(), 'a handful of roos')

# generate xml from layer
layer_doc = QDomDocument("doc")
layer_elem = layer_doc.createElement("maplayer")
Expand Down

0 comments on commit 750a68f

Please sign in to comment.