Skip to content

Commit ac55f39

Browse files
committed
Fix reading project properties fails if any child element
has a tag named "properties"
1 parent be9e93d commit ac55f39

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/core/qgsproject.cpp

+4-12
Original file line numberDiff line numberDiff line change
@@ -519,30 +519,22 @@ scope. "layers" is a list containing three string values.
519519
*/
520520
void _getProperties( const QDomDocument& doc, QgsProjectPropertyKey& project_properties )
521521
{
522-
QDomNodeList properties = doc.elementsByTagName( QStringLiteral( "properties" ) );
522+
QDomElement propertiesElem = doc.documentElement().firstChildElement( QStringLiteral( "properties" ) );
523523

524-
if ( properties.count() > 1 )
525-
{
526-
QgsDebugMsg( "there appears to be more than one ``properties'' XML tag ... bailing" );
527-
return;
528-
}
529-
else if ( properties.count() < 1 ) // no properties found, so we're done
524+
if ( propertiesElem.isNull() ) // no properties found, so we're done
530525
{
531526
return;
532527
}
533528

534-
// item(0) because there should only be ONE "properties" node
535-
QDomNodeList scopes = properties.item( 0 ).childNodes();
529+
QDomNodeList scopes = propertiesElem.childNodes();
536530

537531
if ( scopes.count() < 1 )
538532
{
539533
QgsDebugMsg( "empty ``properties'' XML tag ... bailing" );
540534
return;
541535
}
542536

543-
QDomNode propertyNode = properties.item( 0 );
544-
545-
if ( ! project_properties.readXml( propertyNode ) )
537+
if ( ! project_properties.readXml( propertiesElem ) )
546538
{
547539
QgsDebugMsg( "Project_properties.readXml() failed" );
548540
}

0 commit comments

Comments
 (0)