Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add unique_ptr in nodeLiteralFromOgcFilter
  • Loading branch information
pblottiere committed Sep 13, 2018
1 parent 180d6b3 commit b57b9d7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/core/qgsogcutils.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b57b9d7

Please sign in to comment.