@@ -1124,20 +1124,17 @@ static QVariant fcnGeomFromWKT( const QVariantList& values, const QgsFeature*, Q
1124
1124
{
1125
1125
QString wkt = getStringValue ( values.at ( 0 ), parent );
1126
1126
QgsGeometry* geom = QgsGeometry::fromWkt ( wkt );
1127
- if ( geom )
1128
- return QVariant::fromValue ( *geom );
1129
- else
1130
- return QVariant ();
1127
+ QVariant result = geom ? QVariant::fromValue ( *geom ) : QVariant ();
1128
+ delete geom;
1129
+ return result;
1131
1130
}
1132
1131
static QVariant fcnGeomFromGML ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1133
1132
{
1134
1133
QString gml = getStringValue ( values.at ( 0 ), parent );
1135
1134
QgsGeometry* geom = QgsOgcUtils::geometryFromGML ( gml );
1136
-
1137
- if ( geom )
1138
- return QVariant::fromValue ( *geom );
1139
- else
1140
- return QVariant ();
1135
+ QVariant result = geom ? QVariant::fromValue ( *geom ) : QVariant ();
1136
+ delete geom;
1137
+ return result;
1141
1138
}
1142
1139
1143
1140
static QVariant fcnGeomArea ( const QVariantList&, const QgsFeature* f, QgsExpression* parent )
@@ -1163,14 +1160,9 @@ static QVariant fcnBounds( const QVariantList& values, const QgsFeature*, QgsExp
1163
1160
{
1164
1161
QgsGeometry geom = getGeometry ( values.at ( 0 ), parent );
1165
1162
QgsGeometry* geomBounds = QgsGeometry::fromRect ( geom.boundingBox () );
1166
- if ( geomBounds )
1167
- {
1168
- return QVariant::fromValue ( *geomBounds );
1169
- }
1170
- else
1171
- {
1172
- return QVariant ();
1173
- }
1163
+ QVariant result = geomBounds ? QVariant::fromValue ( *geomBounds ) : QVariant ();
1164
+ delete geomBounds;
1165
+ return result;
1174
1166
}
1175
1167
1176
1168
static QVariant fcnBoundsWidth ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
@@ -1269,34 +1261,34 @@ static QVariant fcnBuffer( const QVariantList& values, const QgsFeature*, QgsExp
1269
1261
seg = getIntValue ( values.at ( 2 ), parent );
1270
1262
1271
1263
QgsGeometry* geom = fGeom .buffer ( dist, seg );
1272
- if ( geom )
1273
- return QVariant::fromValue ( * geom ) ;
1274
- return QVariant () ;
1264
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1265
+ delete geom;
1266
+ return result ;
1275
1267
}
1276
1268
static QVariant fcnCentroid ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1277
1269
{
1278
1270
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1279
1271
QgsGeometry* geom = fGeom .centroid ();
1280
- if ( geom )
1281
- return QVariant::fromValue ( * geom ) ;
1282
- return QVariant () ;
1272
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1273
+ delete geom;
1274
+ return result ;
1283
1275
}
1284
1276
static QVariant fcnConvexHull ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1285
1277
{
1286
1278
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1287
1279
QgsGeometry* geom = fGeom .convexHull ();
1288
- if ( geom )
1289
- return QVariant::fromValue ( * geom ) ;
1290
- return QVariant () ;
1280
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1281
+ delete geom;
1282
+ return result ;
1291
1283
}
1292
1284
static QVariant fcnDifference ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1293
1285
{
1294
1286
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1295
1287
QgsGeometry sGeom = getGeometry ( values.at ( 1 ), parent );
1296
1288
QgsGeometry* geom = fGeom .difference ( &sGeom );
1297
- if ( geom )
1298
- return QVariant::fromValue ( * geom ) ;
1299
- return QVariant () ;
1289
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1290
+ delete geom;
1291
+ return result ;
1300
1292
}
1301
1293
static QVariant fcnDistance ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1302
1294
{
@@ -1309,27 +1301,27 @@ static QVariant fcnIntersection( const QVariantList& values, const QgsFeature*,
1309
1301
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1310
1302
QgsGeometry sGeom = getGeometry ( values.at ( 1 ), parent );
1311
1303
QgsGeometry* geom = fGeom .intersection ( &sGeom );
1312
- if ( geom )
1313
- return QVariant::fromValue ( * geom ) ;
1314
- return QVariant () ;
1304
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1305
+ delete geom;
1306
+ return result ;
1315
1307
}
1316
1308
static QVariant fcnSymDifference ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1317
1309
{
1318
1310
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1319
1311
QgsGeometry sGeom = getGeometry ( values.at ( 1 ), parent );
1320
1312
QgsGeometry* geom = fGeom .symDifference ( &sGeom );
1321
- if ( geom )
1322
- return QVariant::fromValue ( * geom ) ;
1323
- return QVariant () ;
1313
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1314
+ delete geom;
1315
+ return result ;
1324
1316
}
1325
1317
static QVariant fcnCombine ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1326
1318
{
1327
1319
QgsGeometry fGeom = getGeometry ( values.at ( 0 ), parent );
1328
1320
QgsGeometry sGeom = getGeometry ( values.at ( 1 ), parent );
1329
1321
QgsGeometry* geom = fGeom .combine ( &sGeom );
1330
- if ( geom )
1331
- return QVariant::fromValue ( * geom ) ;
1332
- return QVariant () ;
1322
+ QVariant result = geom ? QVariant::fromValue ( * geom ) : QVariant ();
1323
+ delete geom;
1324
+ return result ;
1333
1325
}
1334
1326
static QVariant fcnGeomToWKT ( const QVariantList& values, const QgsFeature*, QgsExpression* parent )
1335
1327
{
0 commit comments