Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Cleanup style upgrade loop
  • Loading branch information
nyalldawson committed Jul 23, 2021
1 parent 19823b7 commit 95e91c3
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/core/symbology/qgsstyle.cpp
Expand Up @@ -2749,13 +2749,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
if ( version == QLatin1String( STYLE_CURRENT_VERSION ) || version == QLatin1String( "1" ) )
{
// For the new style, load symbols individually
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the symbol, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -2787,7 +2786,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
}
else
Expand All @@ -2805,13 +2803,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
// load color ramps
QDomElement rampsElement = docEl.firstChildElement( QStringLiteral( "colorramps" ) );
e = rampsElement.firstChildElement();
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the ramp, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -2843,7 +2840,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}

// load text formats
Expand All @@ -2855,13 +2851,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
const QDomElement textFormatElement = docEl.firstChildElement( QStringLiteral( "textformats" ) );
e = textFormatElement.firstChildElement();
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the format, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -2892,7 +2887,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
}

Expand All @@ -2901,13 +2895,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
const QDomElement labelSettingsElement = docEl.firstChildElement( QStringLiteral( "labelsettings" ) );
e = labelSettingsElement.firstChildElement();
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the settings, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -2938,7 +2931,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
}
}
Expand All @@ -2948,13 +2940,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
const QDomElement legendPatchShapesElement = docEl.firstChildElement( QStringLiteral( "legendpatchshapes" ) );
e = legendPatchShapesElement.firstChildElement();
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the shape, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -2985,7 +2976,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
}

Expand All @@ -2994,13 +2984,12 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
const QDomElement symbols3DElement = docEl.firstChildElement( QStringLiteral( "symbols3d" ) );
e = symbols3DElement.firstChildElement();
while ( !e.isNull() )
for ( ; !e.isNull(); e = e.nextSiblingElement() )
{
const int entityAddedVersion = e.attribute( QStringLiteral( "addedVersion" ) ).toInt();
if ( entityAddedVersion != 0 && sinceVersion != -1 && entityAddedVersion <= sinceVersion )
{
// skip the symbol, should already be present
e = e.nextSiblingElement();
continue;
}

Expand Down Expand Up @@ -3036,7 +3025,6 @@ bool QgsStyle::importXml( const QString &filename, int sinceVersion )
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
}

Expand Down

0 comments on commit 95e91c3

Please sign in to comment.