Skip to content

Commit

Permalink
[layouts] Fix item_variables function with non-lowercase item ids
Browse files Browse the repository at this point in the history
Fixes #19063
  • Loading branch information
nyalldawson committed Jun 8, 2018
1 parent 262a01f commit 57c442a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsexpressioncontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ class GetLayoutItemVariables : public QgsScopedExpressionFunction
if ( !mLayout )
return QVariant();

QString id = values.at( 0 ).toString().toLower();
QString id = values.at( 0 ).toString();

const QgsLayoutItem *item = mLayout->itemById( id );
if ( !item )
Expand Down
10 changes: 5 additions & 5 deletions tests/src/core/testqgslayoutitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ void TestQgsLayoutItem::itemVariablesFunction()
QgsRectangle extent( 2000, 2800, 2500, 2900 );
QgsLayout l( QgsProject::instance() );

QgsExpression e( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_scale' )" ) );
QgsExpression e( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_scale' )" ) );
// no map
QgsExpressionContext c = l.createExpressionContext();
QVariant r = e.evaluate( &c );
Expand All @@ -1414,21 +1414,21 @@ void TestQgsLayoutItem::itemVariablesFunction()
map->attemptSetSceneRect( QRectF( 30, 60, 200, 100 ) );
map->setExtent( extent );
l.addLayoutItem( map );
map->setId( QStringLiteral( "map_id" ) );
map->setId( QStringLiteral( "Map_id" ) );

c = l.createExpressionContext();
r = e.evaluate( &c );
QGSCOMPARENEAR( r.toDouble(), 184764103, 100 );

QgsExpression e2( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_crs' )" ) );
QgsExpression e2( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_crs' )" ) );
r = e2.evaluate( &c );
QCOMPARE( r.toString(), QString( "EPSG:4326" ) );

QgsExpression e3( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_crs_definition' )" ) );
QgsExpression e3( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_crs_definition' )" ) );
r = e3.evaluate( &c );
QCOMPARE( r.toString(), QString( "+proj=longlat +datum=WGS84 +no_defs" ) );

QgsExpression e4( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_units' )" ) );
QgsExpression e4( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_units' )" ) );
r = e4.evaluate( &c );
QCOMPARE( r.toString(), QString( "degrees" ) );
}
Expand Down

0 comments on commit 57c442a

Please sign in to comment.