Skip to content

Commit

Permalink
[layouts] Fix missing layer scope for atlas enabled items
Browse files Browse the repository at this point in the history
Fixes #18525
  • Loading branch information
nyalldawson committed Mar 28, 2018
1 parent 054470f commit 8b59bdc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/layout/qgslayout.cpp
Expand Up @@ -393,6 +393,9 @@ QgsExpressionContext QgsLayout::createExpressionContext() const
QgsExpressionContext context = QgsExpressionContext();
context.appendScope( QgsExpressionContextUtils::globalScope() );
context.appendScope( QgsExpressionContextUtils::projectScope( mProject ) );
if ( mReportContext->layer() )
context.appendScope( QgsExpressionContextUtils::layerScope( mReportContext->layer() ) );

context.appendScope( QgsExpressionContextUtils::layoutScope( this ) );
return context;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/src/core/testqgslayoutcontext.cpp
Expand Up @@ -23,6 +23,7 @@
#include "qgsgeometry.h"
#include "qgsproject.h"
#include "qgslayout.h"
#include "qgsexpressionutils.h"
#include <QObject>
#include "qgstest.h"
#include <QtTest/QSignalSpy>
Expand Down Expand Up @@ -145,6 +146,12 @@ void TestQgsLayoutContext::layer()
context.setLayer( nullptr );
QVERIFY( !context.layer() );

QgsLayout l( QgsProject::instance() );
l.reportContext().setLayer( layer );
//test that expression context created for layout contains report context layer scope
QgsExpressionContext expContext = l.createExpressionContext();
QCOMPARE( QgsExpressionUtils::getVectorLayer( expContext.variable( "layer" ), nullptr ), layer );

delete layer;
}

Expand Down

0 comments on commit 8b59bdc

Please sign in to comment.