Skip to content

Commit

Permalink
Fix memory leak in QgsFeature sip api
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 15, 2013
1 parent b6770be commit 9fc01a6
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions python/core/qgsfeature.sip
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ typedef QVector<QVariant> QgsAttributes;
// Set the list elements.
for (int i = 0; i < sipCpp->size(); ++i)
{
QVariant* v = new QVariant(sipCpp->at(i));
QVariant* v = new QVariant( sipCpp->at(i) );
PyObject *tobj;

if ( v->isNull() )
{
tobj = Py_None;
delete v;
}
else if ((tobj = sipConvertFromType(v, sipType_QVariant,Py_None)) == NULL)
else if ((tobj = sipConvertFromNewType(v, sipType_QVariant,Py_None)) == NULL)
{
delete v;
return NULL;
}

Expand Down Expand Up @@ -200,11 +202,16 @@ class QgsFeature
}
else
{
QVariant* v = new QVariant(attrs[a0]);
QVariant* v = new QVariant(attrs.at(a0));
if ( v->isNull() )
{
delete v;
sipRes = Py_None;
}
else
sipRes = sipConvertFromInstance( v, sipClass_QVariant, Py_None );
{
sipRes = sipConvertFromNewInstance( v, sipClass_QVariant, Py_None );
}
}
%End

Expand Down

0 comments on commit 9fc01a6

Please sign in to comment.