Skip to content
Permalink
Browse files

Fix #8040. Build error with sip

  • Loading branch information
NathanW2 committed Jun 11, 2013
1 parent 6ddaa3e commit 052669f5c5e70d28c8b071fa68cba0b8c87fa4fa
Showing with 12 additions and 12 deletions.
  1. +12 −12 python/core/qgsfeature.sip
@@ -22,14 +22,14 @@ typedef QVector<QVariant> QgsAttributes;
// Set the list elements.
for (int i = 0; i < sipCpp->size(); ++i)
{
const QVariant& v = sipCpp->at(i);
QVariant* v = new QVariant(sipCpp->at(i));

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 12, 2013

Member

Most likely a memory leak: Use sipConvertFromNewInstance to transfer ownership to python and make sure it gets deleted properly in any other path ( like v->IsNull() )

PyObject *tobj;

if ( v.isNull() )
if ( v->isNull() )
{
tobj = Py_None;
}
else if ((tobj = sipConvertFromType(&v, sipType_QVariant,Py_None)) == NULL)
else if ((tobj = sipConvertFromType(v, sipType_QVariant,Py_None)) == NULL)
{
return NULL;
}
@@ -121,15 +121,15 @@ class QgsFeature

if (fieldIdx >= 0)
{
const QVariant& v = sipCpp->attribute(fieldIdx);
QVariant& v = sipCpp->attribute(fieldIdx);
if ( v.isNull() )
sipRes = Py_None;
else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None );
}
else if( altfieldIdx >= 0 )
{
const QVariant& v = sipCpp->attribute(altfieldIdx);
QVariant& v = sipCpp->attribute(altfieldIdx);
if ( v.isNull() )
sipRes = Py_None;
else
@@ -200,11 +200,11 @@ class QgsFeature
}
else
{
const QVariant& v = attrs[a0];
if ( v.isNull() )
QVariant* v = new QVariant(attrs[a0]);
if ( v->isNull() )
sipRes = Py_None;
else
sipRes = sipConvertFromInstance( &v, sipClass_QVariant, Py_None );
sipRes = sipConvertFromInstance( v, sipClass_QVariant, Py_None );
}
%End

@@ -218,7 +218,7 @@ class QgsFeature
}
else
{
const QVariant& v = sipCpp->attribute(fieldIdx);
QVariant& v = sipCpp->attribute(fieldIdx);
if ( v.isNull() )
sipRes = Py_None;
else
@@ -258,7 +258,7 @@ class QgsFeature
{
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute(a0, QVariant( QVariant::Int ) );
sipCpp->setAttribute(*a0, QVariant( QVariant::Int ) );
}
else
{
@@ -422,7 +422,7 @@ class QgsFeature
{
if ( a1Wrapper == Py_None )
{
sipCpp->setAttribute(a0, QVariant( QVariant::Int ) );
sipCpp->setAttribute(*a0, QVariant( QVariant::Int ) );
}
else
{
@@ -463,7 +463,7 @@ class QgsFeature
}
else
{
const QVariant& v = sipCpp->attribute(fieldIdx);
QVariant& v = sipCpp->attribute(fieldIdx);
if ( v.isNull() )
sipRes = Py_None;
else

1 comment on commit 052669f

@slarosa

This comment has been minimized.

Copy link
Member

@slarosa slarosa commented on 052669f Jun 11, 2013

Hi Nathan,
just compiled under Linux I am getting:

[ 88%] Building CXX object python/CMakeFiles/python_module_qgis_core.dir/core/sipcorepart3.cpp.o
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip: In function ‘PyObject* meth_QgsFeature___getattr__(PyObject*, PyObject*)’:
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip:124:47: error: invalid initialization of non-const reference of type ‘QVariant&’ from an rvalue of type ‘QVariant’
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip:132:50: error: invalid initialization of non-const reference of type ‘QVariant&’ from an rvalue of type ‘QVariant’
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip: In function ‘PyObject* meth_QgsFeature_attribute(PyObject*, PyObject*)’:
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip:466:45: error: invalid initialization of non-const reference of type ‘QVariant&’ from an rvalue of type ‘QVariant’
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip: In function ‘PyObject* slot_QgsFeature___getitem__(PyObject*, PyObject*)’:
/home/sam/pacchetti_gis/Quantum-GIS/python/core/qgsfeature.sip:221:45: error: invalid initialization of non-const reference of type ‘QVariant&’ from an rvalue of type ‘QVariant’
make[2]: *** [python/CMakeFiles/python_module_qgis_core.dir/core/sipcorepart3.cpp.o] Error 1
make[1]: *** [python/CMakeFiles/python_module_qgis_core.dir/all] Error 2
make: *** [all] Error 2
Please sign in to comment.
You can’t perform that action at this time.