Skip to content
Permalink
Browse files

[layouts] Fix missing layer scope for atlas enabled items

Fixes #18525
  • Loading branch information
nyalldawson committed Mar 27, 2018
1 parent 054470f commit 8b59bdcc942648495826ac7dbfdb793b2a176e8c
Showing with 10 additions and 0 deletions.
  1. +3 −0 src/core/layout/qgslayout.cpp
  2. +7 −0 tests/src/core/testqgslayoutcontext.cpp
@@ -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;
}
@@ -23,6 +23,7 @@
#include "qgsgeometry.h"
#include "qgsproject.h"
#include "qgslayout.h"
#include "qgsexpressionutils.h"
#include <QObject>
#include "qgstest.h"
#include <QtTest/QSignalSpy>
@@ -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;
}

0 comments on commit 8b59bdc

Please sign in to comment.
You can’t perform that action at this time.