Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[layouts] Fix loss of composition variables when converting 2.x compo…
…sitions

(cherry picked from commit 83340d0)
  • Loading branch information
nyalldawson committed Jan 17, 2019
1 parent 19f0e02 commit 42254b4
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
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
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
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 42254b4

Please sign in to comment.