Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix metadata address element doubles with each project write
elementsByTagName can be dangerous, because it returns children
recursively. In this case the contact "address" element contained
a child element for the street address, also named "address".

So when restoring a project with contact addresses in the metadata,
each address was created twice...

Fixes #17940
  • Loading branch information
nyalldawson committed Jan 24, 2018
1 parent 5812934 commit 36bf093
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/metadata/qgslayermetadata.cpp
Expand Up @@ -440,7 +440,7 @@ bool QgsLayerMetadata::readMetadataXml( const QDomElement &metadataElement )
oneContact.role = mne.namedItem( QStringLiteral( "role" ) ).toElement().text();

QList< QgsLayerMetadata::Address > addresses;
QDomNodeList addressList = mne.elementsByTagName( QStringLiteral( "address" ) );
QDomNodeList addressList = mne.elementsByTagName( QStringLiteral( "contactAddress" ) );
for ( int j = 0; j < addressList.size(); j++ )
{
QDomElement addressElement = addressList.at( j ).toElement();
Expand Down Expand Up @@ -663,7 +663,7 @@ bool QgsLayerMetadata::writeMetadataXml( QDomElement &metadataElement, QDomDocum

for ( const QgsLayerMetadata::Address &oneAddress : contact.addresses )
{
QDomElement addressElement = document.createElement( QStringLiteral( "address" ) );
QDomElement addressElement = document.createElement( QStringLiteral( "contactAddress" ) );
QDomElement typeElement = document.createElement( QStringLiteral( "type" ) );
QDomElement addressDetailedElement = document.createElement( QStringLiteral( "address" ) );
QDomElement cityElement = document.createElement( QStringLiteral( "city" ) );
Expand Down

0 comments on commit 36bf093

Please sign in to comment.