Skip to content

Commit 11195d3

Browse files
author
mhugent
committed
Fix for save and read layer properties
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15849 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent af9203a commit 11195d3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/core/qgsmaplayer.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,10 @@ void QgsMapLayer::readCustomProperties( const QDomNode& layerNode, const QString
846846
if ( propsNode.isNull() ) // no properties stored...
847847
return;
848848

849-
mCustomProperties.clear();
849+
if ( keyStartsWith.isEmpty() )
850+
{
851+
mCustomProperties.clear();
852+
}
850853

851854
QDomNodeList nodes = propsNode.childNodes();
852855

@@ -869,6 +872,13 @@ void QgsMapLayer::readCustomProperties( const QDomNode& layerNode, const QString
869872

870873
void QgsMapLayer::writeCustomProperties( QDomNode & layerNode, QDomDocument & doc ) const
871874
{
875+
//remove already existing <customproperties> tags
876+
QDomNodeList propertyList = layerNode.toElement().elementsByTagName( "customproperties" );
877+
for ( int i = 0; i < propertyList.size(); ++i )
878+
{
879+
layerNode.removeChild( propertyList.at( i ) );
880+
}
881+
872882
QDomElement propsElement = doc.createElement( "customproperties" );
873883

874884
for ( QMap<QString, QVariant>::const_iterator it = mCustomProperties.constBegin(); it != mCustomProperties.constEnd(); ++it )

0 commit comments

Comments
 (0)