Skip to content

Commit

Permalink
Make QgsExpressionUtils::get***Layer functions require an expression …
Browse files Browse the repository at this point in the history
…context
  • Loading branch information
nyalldawson committed Dec 13, 2022
1 parent 66b999e commit 2f251b9
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 108 deletions.
6 changes: 2 additions & 4 deletions src/core/expression/qgsexpressioncontextutils.cpp
Expand Up @@ -22,8 +22,6 @@
#include "qgsprocessingmodelalgorithm.h"
#include "qgsprocessingalgorithm.h"
#include "qgsmapsettings.h"
#include "qgssymbollayerutils.h"
#include "qgslayout.h"
#include "qgslayoutitem.h"
#include "qgsexpressionutils.h"
#include "qgslayoutpagecollection.h"
Expand Down Expand Up @@ -959,15 +957,15 @@ QgsExpressionContextUtils::GetLayerVisibility::GetLayerVisibility()
: QgsScopedExpressionFunction( QStringLiteral( "is_layer_visible" ), QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral( "id" ) ), QStringLiteral( "General" ) )
{}

QVariant QgsExpressionContextUtils::GetLayerVisibility::func( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
QVariant QgsExpressionContextUtils::GetLayerVisibility::func( const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction * )
{
if ( mLayers.isEmpty() )
{
return false;
}

bool isVisible = false;
QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), context, parent );
if ( layer && mLayers.contains( layer ) )
{
isVisible = true;
Expand Down

0 comments on commit 2f251b9

Please sign in to comment.