Skip to content
Permalink
Browse files
Optimise expression context creation
Sponsored by DB Fahrwegdienste GmbH
  • Loading branch information
nyalldawson committed Aug 30, 2016
1 parent 8ae7e3f commit 6d28eb5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
@@ -7345,11 +7345,7 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
remap.insert( idx, dst );
}

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( pasteVectorLayer );

QgsExpressionContext context = pasteVectorLayer->createExpressionContext();
int dstAttrCount = pasteVectorLayer->fields().count();

QgsFeatureList::iterator featureIt = features.begin();
@@ -145,10 +145,7 @@ bool QgsFeatureAction::addFeature( const QgsAttributeMap& defaultAttributes, boo
bool reuseLastValues = settings.value( "/qgis/digitizing/reuseLastValues", false ).toBool();
QgsDebugMsg( QString( "reuseLastValues: %1" ).arg( reuseLastValues ) );

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );
QgsExpressionContext context = mLayer->createExpressionContext();

// add the fields to the QgsFeature
const QgsFields& fields = mLayer->fields();
@@ -523,10 +523,7 @@ QgsAttributes QgsMergeAttributesDialog::mergedAttributes() const
return QgsAttributes();
}

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mVectorLayer );
QgsExpressionContext context = mVectorLayer->createExpressionContext();

int widgetIndex = 0;
QgsAttributes results( mFields.count() );
@@ -737,10 +737,7 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer* offlineLayer, QgsVec

QgsFields remoteFlds = remoteLayer->fields();

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( remoteLayer );
QgsExpressionContext context = remoteLayer->createExpressionContext();

// get new features from offline layer
QgsFeatureList features;

0 comments on commit 6d28eb5

Please sign in to comment.