Skip to content
Permalink
Browse files

Fix crash when using expression editor in aggregate algorithm

  • Loading branch information
github-actions authored and nyalldawson committed Jul 12, 2020
1 parent ecef38f commit a5f18a5897127304b2c9255467815f21e2eddb1c
@@ -34,7 +34,7 @@
QgsAggregateMappingModel::QgsAggregateMappingModel( const QgsFields &sourceFields,
QObject *parent )
: QAbstractTableModel( parent )
, mExpressionContextGenerator( new QgsFieldMappingModel::ExpressionContextGenerator( &sourceFields ) )
, mExpressionContextGenerator( new QgsFieldMappingModel::ExpressionContextGenerator( sourceFields ) )
{
setSourceFields( sourceFields );
}
@@ -24,7 +24,7 @@ QgsFieldMappingModel::QgsFieldMappingModel( const QgsFields &sourceFields,
QObject *parent )
: QAbstractTableModel( parent )
, mSourceFields( sourceFields )
, mExpressionContextGenerator( new ExpressionContextGenerator( &mSourceFields ) )
, mExpressionContextGenerator( new ExpressionContextGenerator( mSourceFields ) )
{
setDestinationFields( destinationFields, expressions );
}
@@ -494,7 +494,7 @@ bool QgsFieldMappingModel::moveDown( const QModelIndex &index )
return moveUpOrDown( index, false );
}

QgsFieldMappingModel::ExpressionContextGenerator::ExpressionContextGenerator( const QgsFields *sourceFields )
QgsFieldMappingModel::ExpressionContextGenerator::ExpressionContextGenerator( const QgsFields &sourceFields )
: mSourceFields( sourceFields )
{
}
@@ -505,16 +505,16 @@ QgsExpressionContext QgsFieldMappingModel::ExpressionContextGenerator::createExp
{
QgsExpressionContext ctx = mBaseGenerator->createExpressionContext();
std::unique_ptr< QgsExpressionContextScope > fieldMappingScope = qgis::make_unique< QgsExpressionContextScope >( tr( "Field Mapping" ) );
fieldMappingScope->setFields( *mSourceFields );
fieldMappingScope->setFields( mSourceFields );
ctx.appendScope( fieldMappingScope.release() );
return ctx;
}
else
{
QgsExpressionContext ctx;
ctx.appendScope( QgsExpressionContextUtils::globalScope() );
ctx.setFields( *mSourceFields );
QgsFeature feature { *mSourceFields };
ctx.setFields( mSourceFields );
QgsFeature feature { mSourceFields };
feature.setValid( true );
ctx.setFeature( feature );
return ctx;
@@ -160,7 +160,7 @@ class GUI_EXPORT QgsFieldMappingModel: public QAbstractTableModel

public:

ExpressionContextGenerator( const QgsFields *sourceFields );
ExpressionContextGenerator( const QgsFields &sourceFields );

// QgsExpressionContextGenerator interface
QgsExpressionContext createExpressionContext() const override;
@@ -170,7 +170,7 @@ class GUI_EXPORT QgsFieldMappingModel: public QAbstractTableModel

const QgsExpressionContextGenerator *mBaseGenerator = nullptr;

const QgsFields *mSourceFields;
const QgsFields mSourceFields;

};

0 comments on commit a5f18a5

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