Skip to content

Commit

Permalink
[layouts] Fix loss of composition variables when converting 2.x compo…
Browse files Browse the repository at this point in the history
…sitions
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent cabcce1 commit 83340d0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core/layout/qgscompositionconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ std::unique_ptr< QgsPrintLayout > QgsCompositionConverter::createLayoutFromCompo
std::unique_ptr< QgsPrintLayout > layout = qgis::make_unique< QgsPrintLayout >( project );
layout->undoStack()->blockCommands( true );

layout->mCustomProperties.readXml( composerElement );

// Guides
layout->guides().setVisible( composerElement.attribute( QStringLiteral( "guidesVisible" ), QStringLiteral( "1" ) ).toInt() != 0 );

Expand Down
5 changes: 5 additions & 0 deletions tests/src/core/testqgscompositionconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ void TestQgsCompositionConverter::convertComposition()
QCOMPARE( layout->name(), QStringLiteral( "composer title" ) );
QCOMPARE( layout->renderContext().dpi(), 305.0 );

QStringList variableNames = layout->customProperty( QStringLiteral( "variableNames" ) ).toStringList();
QStringList variableValues = layout->customProperty( QStringLiteral( "variableValues" ) ).toStringList();
QCOMPARE( variableNames, QStringList() << QStringLiteral( "variable1" ) << QStringLiteral( "variable2" ) );
QCOMPARE( variableValues, QStringList() << QStringLiteral( "100" ) << QStringLiteral( "200" ) );

// Check guides
QCOMPARE( layout->guides().rowCount( QModelIndex() ), 8 );

Expand Down
11 changes: 10 additions & 1 deletion tests/testdata/layouts/sample_project.qgs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,16 @@
</ComposerFrame>
<customproperties/>
</ComposerAttributeTableV2>
<customproperties/>
<customproperties>
<property key="variableNames">
<value>variable1</value>
<value>variable2</value>
</property>
<property key="variableValues">
<value>100</value>
<value>200</value>
</property>
</customproperties>
</Composition>
</Composer>
<Composer title="composer atlas" visible="0">
Expand Down

0 comments on commit 83340d0

Please sign in to comment.