@@ -3313,23 +3313,21 @@ QgsExpressionNode *QgsOgcUtilsExpressionFromFilter::nodeLiteralFromOgcFilter( co
3313
3313
return nullptr ;
3314
3314
}
3315
3315
3316
- QgsExpressionNode * root = nullptr ;
3316
+ std::unique_ptr< QgsExpressionNode> root;
3317
3317
3318
3318
// the literal content can have more children (e.g. CDATA section, text, ...)
3319
3319
QDomNode childNode = element.firstChild ();
3320
3320
while ( !childNode.isNull () )
3321
3321
{
3322
- QgsExpressionNode * operand = nullptr ;
3322
+ std::unique_ptr< QgsExpressionNode> operand;
3323
3323
3324
3324
if ( childNode.nodeType () == QDomNode::ElementNode )
3325
3325
{
3326
3326
// found a element node (e.g. PropertyName), convert it
3327
3327
QDomElement operandElem = childNode.toElement ();
3328
- operand = nodeFromOgcFilter ( operandElem );
3328
+ operand. reset ( nodeFromOgcFilter ( operandElem ) );
3329
3329
if ( !operand )
3330
3330
{
3331
- delete root;
3332
-
3333
3331
mErrorMessage = QObject::tr ( " '%1' is an invalid or not supported content for %2:Literal" ).arg ( operandElem.tagName (), mPrefix );
3334
3332
return nullptr ;
3335
3333
}
@@ -3370,26 +3368,26 @@ QgsExpressionNode *QgsOgcUtilsExpressionFromFilter::nodeLiteralFromOgcFilter( co
3370
3368
value = d;
3371
3369
}
3372
3370
3373
- operand = new QgsExpressionNodeLiteral ( value );
3371
+ operand. reset ( new QgsExpressionNodeLiteral ( value ) );
3374
3372
if ( !operand )
3375
3373
continue ;
3376
3374
}
3377
3375
3378
3376
// use the concat operator to merge the ogc:Literal children
3379
3377
if ( !root )
3380
3378
{
3381
- root = operand;
3379
+ root = std::move ( operand ) ;
3382
3380
}
3383
3381
else
3384
3382
{
3385
- root = new QgsExpressionNodeBinaryOperator ( QgsExpressionNodeBinaryOperator::boConcat, root, operand );
3383
+ root. reset ( new QgsExpressionNodeBinaryOperator ( QgsExpressionNodeBinaryOperator::boConcat, root. release () , operand. release () ) );
3386
3384
}
3387
3385
3388
3386
childNode = childNode.nextSibling ();
3389
3387
}
3390
3388
3391
3389
if ( root )
3392
- return root;
3390
+ return root. release () ;
3393
3391
3394
3392
return nullptr ;
3395
3393
}
0 commit comments