Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add project/layer expression context scope only if it is available
Better to leave them out than adding dummy scopes
  • Loading branch information
wonder-sk committed Jan 6, 2017
1 parent 63d1cfd commit 062de6a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/core/qgsexpressioncontext.cpp
Expand Up @@ -686,9 +686,14 @@ QgsExpressionContextScope* QgsExpressionContextUtils::layerScope( const QgsMapLa
QList<QgsExpressionContextScope*> QgsExpressionContextUtils::globalProjectLayerScopes( const QgsMapLayer* layer )
{
QList<QgsExpressionContextScope*> scopes;
scopes << globalScope()
<< projectScope( QgsProject::instance() ) // TODO: use project associated with layer
<< layerScope( layer );
scopes << globalScope();

QgsProject* project = QgsProject::instance(); // TODO: use project associated with layer
if ( project )
scopes << projectScope( project );

if ( layer )
scopes << layerScope( layer );
return scopes;
}

Expand Down
3 changes: 2 additions & 1 deletion src/gui/symbology-ng/qgssymbolwidgetcontext.cpp
Expand Up @@ -93,6 +93,7 @@ QList<QgsExpressionContextScope *> QgsSymbolWidgetContext::globalProjectAtlasMap
{
scopes << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() );
}
scopes << QgsExpressionContextUtils::layerScope( layer );
if ( layer )
scopes << QgsExpressionContextUtils::layerScope( layer );
return scopes;
}

0 comments on commit 062de6a

Please sign in to comment.