@@ -3319,23 +3319,19 @@ static QVariant fcnGetFeatureById( const QVariantList &values, const QgsExpressi
3319
3319
{
3320
3320
QVariant result;
3321
3321
QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer ( values.at ( 0 ), parent );
3322
- if ( !vl )
3323
- return result;
3322
+ if ( vl )
3323
+ {
3324
+ QgsFeatureId fid = QgsExpressionUtils::getIntValue ( values.at ( 1 ), parent );
3324
3325
3325
- QgsFeatureId fid = QgsExpressionUtils::getIntValue ( values.at ( 1 ), parent );
3326
+ QgsFeatureRequest req;
3327
+ req.setFilterFid ( fid );
3328
+ req.setLimit ( 1 );
3329
+ QgsFeatureIterator fIt = vl->getFeatures ( req );
3326
3330
3327
- QgsFeatureRequest req;
3328
- req.setFilterFid ( fid );
3329
- req.setLimit ( 1 );
3330
- if ( !parent->needsGeometry () )
3331
- {
3332
- req.setFlags ( QgsFeatureRequest::NoGeometry );
3331
+ QgsFeature fet;
3332
+ if ( fIt .nextFeature ( fet ) )
3333
+ result = QVariant::fromValue ( fet );
3333
3334
}
3334
- QgsFeatureIterator fIt = vl->getFeatures ( req );
3335
-
3336
- QgsFeature fet;
3337
- if ( fIt .nextFeature ( fet ) )
3338
- result = QVariant::fromValue ( fet );
3339
3335
3340
3336
return result;
3341
3337
}
@@ -3378,18 +3374,7 @@ static QVariant fcnGetFeature( const QVariantList &values, const QgsExpressionCo
3378
3374
3379
3375
static QVariant fcnGetLayerProperty ( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent )
3380
3376
{
3381
- QString layerIdOrName = QgsExpressionUtils::getStringValue ( values.at ( 0 ), parent );
3382
-
3383
- // try to find a matching layer by name
3384
- QgsMapLayer *layer = QgsProject::instance ()->mapLayer ( layerIdOrName ); // search by id first
3385
- if ( !layer )
3386
- {
3387
- QList<QgsMapLayer *> layersByName = QgsProject::instance ()->mapLayersByName ( layerIdOrName );
3388
- if ( !layersByName.isEmpty () )
3389
- {
3390
- layer = layersByName.at ( 0 );
3391
- }
3392
- }
3377
+ QgsMapLayer *layer = QgsExpressionUtils::getMapLayer ( values.at ( 0 ), parent );
3393
3378
3394
3379
if ( !layer )
3395
3380
return QVariant ();
@@ -4303,7 +4288,7 @@ const QList<QgsExpressionFunction *> &QgsExpression::Functions()
4303
4288
}
4304
4289
4305
4290
QgsWithVariableExpressionFunction::QgsWithVariableExpressionFunction ()
4306
- : QgsExpressionFunction( QStringLiteral(" with_variable" ), 3, QCoreApplication::tr( " General" ) )
4291
+ : QgsExpressionFunction( QStringLiteral( " with_variable" ), 3, QCoreApplication::tr( " General" ) )
4307
4292
{
4308
4293
4309
4294
}
0 commit comments