Skip to content
Permalink
Browse files

Only use distance area calculator in expression preview results

when it has been initialized correctly

Fixes #35628
  • Loading branch information
nyalldawson committed May 5, 2020
1 parent 0ada65b commit fdce7e2c448de03b1820e09afb34294b337c0005
Showing with 5 additions and 3 deletions.
  1. +4 −3 src/gui/qgsexpressionpreviewwidget.cpp
  2. +1 −0 src/gui/qgsexpressionpreviewwidget.h
@@ -55,6 +55,7 @@ void QgsExpressionPreviewWidget::setCurrentFeature( const QgsFeature &feature )
void QgsExpressionPreviewWidget::setGeomCalculator( const QgsDistanceArea &da )
{
mDa = da;
mUseGeomCalculator = true;
}

void QgsExpressionPreviewWidget::setExpressionContext( const QgsExpressionContext &context )
@@ -78,10 +79,10 @@ void QgsExpressionPreviewWidget::refreshPreview()
{
mExpression = QgsExpression( mExpressionText );

if ( mLayer )
if ( mUseGeomCalculator )
{
// TODO: is this OK?
// Only set calculator if we have layer, else use default.
// only set an explicit geometry calculator if a call to setGeomCalculator was made. If not,
// let the expression context handle this correctly
mExpression.setGeomCalculator( &mDa );
}

@@ -123,6 +123,7 @@ class GUI_EXPORT QgsExpressionPreviewWidget : public QWidget, private Ui::QgsExp
QgsVectorLayer *mLayer = nullptr;
QgsExpressionContext mExpressionContext;
QgsDistanceArea mDa;
bool mUseGeomCalculator = false;
QString mToolTip;
bool mEvalError = true;
bool mParserError = true;

0 comments on commit fdce7e2

Please sign in to comment.
You can’t perform that action at this time.