Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixes #6897
  • Loading branch information
Arunmozhi committed Dec 27, 2012
1 parent ee367d2 commit 8b98197
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
41 changes: 29 additions & 12 deletions src/core/symbology-ng/qgsstylev2.cpp
Expand Up @@ -1351,30 +1351,47 @@ bool QgsStyleV2::importXML( QString filename )
}

QString version = docEl.attribute( "version" );
if ( version != STYLE_CURRENT_VERSION )
if ( version != STYLE_CURRENT_VERSION && version != "0" )
{
mErrorString = "Unknown style file version: " + version;
return false;
}

// load symbols
QgsSymbolV2Map symbols;

QDomElement symbolsElement = docEl.firstChildElement( "symbols" );
QDomElement e = symbolsElement.firstChildElement();
while ( !e.isNull() )

if ( version == STYLE_CURRENT_VERSION )
{
if ( e.tagName() == "symbol" )
// For the new style, load symbols individualy
while ( !e.isNull() )
{
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol( e );
if ( symbol )
if ( e.tagName() == "symbol" )
{
addSymbol( e.attribute( "name" ), symbol );
QgsSymbolV2* symbol = QgsSymbolLayerV2Utils::loadSymbol( e );
if ( symbol )
{
symbols.insert( e.attribute( "name" ), symbol );
}
}
else
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
else
{
QgsDebugMsg( "unknown tag: " + e.tagName() );
}
e = e.nextSiblingElement();
}
else
{
// for the old version, use the utility function to solve @symbol@layer subsymbols
symbols = QgsSymbolLayerV2Utils::loadSymbols( symbolsElement );
}

// save the symbols with proper name
for ( QMap<QString, QgsSymbolV2*>::iterator it = symbols.begin(); it != symbols.end(); it++ )
{
addSymbol( it.key(), it.value() );
}

// load color ramps
Expand Down
1 change: 0 additions & 1 deletion src/core/symbology-ng/qgssymbollayerv2utils.cpp
Expand Up @@ -2305,7 +2305,6 @@ void QgsSymbolLayerV2Utils::saveProperties( QgsStringMap props, QDomDocument& do
}
}

// XXX Not used by QgStyleV2 anymore, But renderers use it still
QgsSymbolV2Map QgsSymbolLayerV2Utils::loadSymbols( QDomElement& element )
{
// go through symbols one-by-one and load them
Expand Down

0 comments on commit 8b98197

Please sign in to comment.