Skip to content

Commit 238b0de

Browse files
author
mhugent
committed
Better fix for restoring custom layer properties
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15856 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 68a0ea1 commit 238b0de

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/core/qgsmaplayer.cpp

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

849-
if ( keyStartsWith.isEmpty() )
849+
if ( !keyStartsWith.isEmpty() )
850+
{
851+
//remove old keys
852+
QStringList keysToRemove;
853+
QMap<QString, QVariant>::const_iterator pIt = mCustomProperties.constBegin();
854+
for ( ; pIt != mCustomProperties.constEnd(); ++pIt )
855+
{
856+
if ( pIt.key().startsWith( keyStartsWith ) )
857+
{
858+
keysToRemove.push_back( pIt.key() );
859+
}
860+
}
861+
862+
QStringList::const_iterator sIt = keysToRemove.constBegin();
863+
for ( ; sIt != keysToRemove.constEnd(); ++sIt )
864+
{
865+
mCustomProperties.remove( *sIt );
866+
}
867+
}
868+
else
850869
{
851870
mCustomProperties.clear();
852871
}

0 commit comments

Comments
 (0)