Skip to content
Permalink
Browse files
[layouts] Fix missing layer scope for atlas enabled items
Fixes #18525

(cherry-picked from 8b59bdc)
  • Loading branch information
nyalldawson committed Apr 2, 2018
1 parent 5672767 commit 842ec80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
@@ -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 842ec80

Please sign in to comment.