Skip to content
Permalink
Browse files

Add unique_ptr in nodeLiteralFromOgcFilter

  • Loading branch information
pblottiere committed Sep 13, 2018
1 parent 180d6b3 commit b57b9d7f849f9cfeaf7ef5bea950153a49c1cdcc
Showing with 7 additions and 9 deletions.
  1. +7 −9 src/core/qgsogcutils.cpp
@@ -3313,23 +3313,21 @@ QgsExpressionNode *QgsOgcUtilsExpressionFromFilter::nodeLiteralFromOgcFilter( co
return nullptr;
}

QgsExpressionNode *root = nullptr;
std::unique_ptr<QgsExpressionNode> root;

// the literal content can have more children (e.g. CDATA section, text, ...)
QDomNode childNode = element.firstChild();
while ( !childNode.isNull() )
{
QgsExpressionNode *operand = nullptr;
std::unique_ptr<QgsExpressionNode> operand;

if ( childNode.nodeType() == QDomNode::ElementNode )
{
// found a element node (e.g. PropertyName), convert it
QDomElement operandElem = childNode.toElement();
operand = nodeFromOgcFilter( operandElem );
operand.reset( nodeFromOgcFilter( operandElem ) );
if ( !operand )
{
delete root;

mErrorMessage = QObject::tr( "'%1' is an invalid or not supported content for %2:Literal" ).arg( operandElem.tagName(), mPrefix );
return nullptr;
}
@@ -3370,26 +3368,26 @@ QgsExpressionNode *QgsOgcUtilsExpressionFromFilter::nodeLiteralFromOgcFilter( co
value = d;
}

operand = new QgsExpressionNodeLiteral( value );
operand.reset( new QgsExpressionNodeLiteral( value ) );
if ( !operand )
continue;
}

// use the concat operator to merge the ogc:Literal children
if ( !root )
{
root = operand;
root = std::move( operand );
}
else
{
root = new QgsExpressionNodeBinaryOperator( QgsExpressionNodeBinaryOperator::boConcat, root, operand );
root.reset( new QgsExpressionNodeBinaryOperator( QgsExpressionNodeBinaryOperator::boConcat, root.release(), operand.release() ) );
}

childNode = childNode.nextSibling();
}

if ( root )
return root;
return root.release();

return nullptr;
}

0 comments on commit b57b9d7

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