Skip to content

Commit 57c442a

Browse files
committedJun 8, 2018
[layouts] Fix item_variables function with non-lowercase item ids
Fixes #19063
1 parent 262a01f commit 57c442a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎src/core/qgsexpressioncontext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ class GetLayoutItemVariables : public QgsScopedExpressionFunction
677677
if ( !mLayout )
678678
return QVariant();
679679

680-
QString id = values.at( 0 ).toString().toLower();
680+
QString id = values.at( 0 ).toString();
681681

682682
const QgsLayoutItem *item = mLayout->itemById( id );
683683
if ( !item )

‎tests/src/core/testqgslayoutitem.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ void TestQgsLayoutItem::itemVariablesFunction()
14031403
QgsRectangle extent( 2000, 2800, 2500, 2900 );
14041404
QgsLayout l( QgsProject::instance() );
14051405

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

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

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

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

1431-
QgsExpression e4( QStringLiteral( "map_get( item_variables( 'map_id' ), 'map_units' )" ) );
1431+
QgsExpression e4( QStringLiteral( "map_get( item_variables( 'Map_id' ), 'map_units' )" ) );
14321432
r = e4.evaluate( &c );
14331433
QCOMPARE( r.toString(), QString( "degrees" ) );
14341434
}

0 commit comments

Comments
 (0)
Please sign in to comment.