Skip to content

Commit

Permalink
Fix wrong python None type reference counting
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jun 19, 2013
1 parent 3186306 commit c1cd3e8
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions python/core/qgsfeature.sip
Expand Up @@ -27,6 +27,7 @@ typedef QVector<QVariant> QgsAttributes;


if ( v->isNull() ) if ( v->isNull() )
{ {
Py_INCREF( Py_None );
tobj = Py_None; tobj = Py_None;
delete v; delete v;
} }
Expand Down Expand Up @@ -125,17 +126,23 @@ class QgsFeature
{ {
QVariant v = sipCpp->attribute(fieldIdx); QVariant v = sipCpp->attribute(fieldIdx);
if ( v.isNull() ) if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None; sipRes = Py_None;
}
else else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None ); sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
} }
else if( altfieldIdx >= 0 ) else if( altfieldIdx >= 0 )
{ {
QVariant v = sipCpp->attribute(altfieldIdx); QVariant v = sipCpp->attribute(altfieldIdx);
if ( v.isNull() ) if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None; sipRes = Py_None;
}
else else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None ); sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
} }
else else
{ {
Expand Down Expand Up @@ -206,11 +213,12 @@ class QgsFeature
if ( v->isNull() ) if ( v->isNull() )
{ {
delete v; delete v;
Py_INCREF( Py_None );
sipRes = Py_None; sipRes = Py_None;
} }
else else
{ {
sipRes = sipConvertFromNewInstance( v, sipClass_QVariant, Py_None ); sipRes = sipConvertFromNewType( v, sipType_QVariant, Py_None );
} }
} }
%End %End
Expand All @@ -227,9 +235,12 @@ class QgsFeature
{ {
QVariant v = sipCpp->attribute(fieldIdx); QVariant v = sipCpp->attribute(fieldIdx);
if ( v.isNull() ) if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None; sipRes = Py_None;
}
else else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None ); sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
} }
%End %End


Expand Down Expand Up @@ -472,9 +483,12 @@ class QgsFeature
{ {
QVariant v = sipCpp->attribute(fieldIdx); QVariant v = sipCpp->attribute(fieldIdx);
if ( v.isNull() ) if ( v.isNull() )
{
Py_INCREF( Py_None );
sipRes = Py_None; sipRes = Py_None;
}
else else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None ); sipRes = sipConvertFromType( &v, sipType_QVariant, Py_None );
} }
%End %End
/** Utility method to get attribute index from name. Returns -1 if field does not exist or field map is not associated. /** Utility method to get attribute index from name. Returns -1 if field does not exist or field map is not associated.
Expand Down

0 comments on commit c1cd3e8

Please sign in to comment.