Add project/layer expression context scope only if it is available

Better to leave them out than adding dummy scopes
This commit is contained in:
Martin Dobias 2017-01-06 10:35:25 +08:00
parent 63d1cfddc8
commit 062de6aeff
2 changed files with 10 additions and 4 deletions

View File

@ -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;
}

View File

@ -93,6 +93,7 @@ QList<QgsExpressionContextScope *> QgsSymbolWidgetContext::globalProjectAtlasMap
{
scopes << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() );
}
if ( layer )
scopes << QgsExpressionContextUtils::layerScope( layer );
return scopes;
}