Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
6 changes: 1 addition & 5 deletions src/app/qgisapp.cpp
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/app/qgsfeatureaction.cpp
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -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() );
Expand Down
5 changes: 1 addition & 4 deletions src/core/qgsofflineediting.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 6d28eb5

Please sign in to comment.