Skip to content

Commit

Permalink
Fix restoration of compositions from legacy projects
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 21, 2017
1 parent 54d1a93 commit c9b8738
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/composer/qgslayoutmanager.cpp
Expand Up @@ -102,19 +102,25 @@ bool QgsLayoutManager::readXml( const QDomElement &element, const QDomDocument &
layoutsElem = element.firstChildElement( QStringLiteral( "Layouts" ) );
}
if ( layoutsElem.isNull() )
return false;
{
// handle legacy projects
layoutsElem = doc.documentElement();
}

//restore each composer
bool result = true;
QDomNodeList composerNodes = element.elementsByTagName( QStringLiteral( "Composer" ) );
for ( int i = 0; i < composerNodes.size(); ++i )
{
QString legacyTitle = composerNodes.at( i ).toElement().attribute( QStringLiteral( "title" ) );
QgsComposition *c = createCompositionFromXml( composerNodes.at( i ).toElement(), doc );
if ( !c )
{
result = false;
continue;
}
if ( c->name().isEmpty() )
c->setName( legacyTitle );
result = result && addComposition( c );
}
return result;
Expand Down

0 comments on commit c9b8738

Please sign in to comment.