Skip to content

Commit

Permalink
Use const pointer for QgsExpression:replaceExpressionText()
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanW2 committed Oct 10, 2013
1 parent f49ea36 commit 2cd8938
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion python/core/qgsexpression.sip
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class QgsExpression
Additional substitutions can be passed through the substitutionMap
parameter
*/
static QString replaceExpressionText( QString action, QgsFeature &feat,
static QString replaceExpressionText( QString action, const QgsFeature *feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap = 0 );
//
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsattributeaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void QgsAttributeAction::doAction( int index, QgsFeature &feat,
return;

// search for expressions while expanding actions
QString expandedAction = QgsExpression::replaceExpressionText( action.action(), feat, mLayer , substitutionMap );
QString expandedAction = QgsExpression::replaceExpressionText( action.action(), &feat, mLayer , substitutionMap );
if ( expandedAction.isEmpty() )
return;

Expand Down
10 changes: 1 addition & 9 deletions src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ void QgsExpression::acceptVisitor( QgsExpression::Visitor& v ) const
mRootNode->accept( v );
}

QString QgsExpression::replaceExpressionText( QString action, QgsFeature* feat,
QString QgsExpression::replaceExpressionText( QString action, const QgsFeature* feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap )
{
Expand Down Expand Up @@ -1796,14 +1796,6 @@ QString QgsExpression::replaceExpressionText( QString action, QgsFeature* feat,
}


QString QgsExpression::replaceExpressionText( QString action, QgsFeature& feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap )
{
return replaceExpressionText( action, &feat, layer, substitutionMap );
}


///////////////////////////////////////////////
// nodes

Expand Down
7 changes: 1 addition & 6 deletions src/core/qgsexpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,7 @@ class CORE_EXPORT QgsExpression
Additional substitutions can be passed through the substitutionMap
parameter
*/
static QString replaceExpressionText( QString action, QgsFeature* feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap = 0 );


static QString replaceExpressionText( QString action, QgsFeature& feat,
static QString replaceExpressionText( const QString action, const QgsFeature* feat,
QgsVectorLayer* layer,
const QMap<QString, QVariant> *substitutionMap = 0 );
enum UnaryOperator
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgshtmlannotationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void QgsHtmlAnnotationItem::setFeatureForMapPosition()
mFeatureId = currentFeatureId;
mFeature = currentFeature;

QString newtext = QgsExpression::replaceExpressionText( mHtmlSource, mFeature, vectorLayer() );
QString newtext = QgsExpression::replaceExpressionText( mHtmlSource, &mFeature, vectorLayer() );
mWebView->setHtml( newtext );
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmaptip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ QString QgsMapTip::fetchFeature( QgsMapLayer *layer, QgsPoint &mapPosition, QgsM

int idx = vlayer->fieldNameIndex( vlayer->displayField() );
if ( idx < 0 )
return QgsExpression::replaceExpressionText( vlayer->displayField(), feature, vlayer );
return QgsExpression::replaceExpressionText( vlayer->displayField(), &feature, vlayer );
else
return feature.attribute( idx ).toString();
}

0 comments on commit 2cd8938

Please sign in to comment.