Skip to content
Permalink
Browse files

Fix possible GIL deadlock when iterating features in python

and an exception is thrown
  • Loading branch information
nyalldawson committed Jan 28, 2018
1 parent 285bb06 commit bcbc46b56ba541ee03a323b2cdce998403e9f1ab
Showing with 14 additions and 8 deletions.
  1. +7 −4 python/core/qgsfeatureiterator.sip.in
  2. +7 −4 src/core/qgsfeatureiterator.h
@@ -201,12 +201,15 @@ Wrapper for iterator of features from vector data provider or vector layer

SIP_PYOBJECT __next__();
%MethodCode
QgsFeature *f = new QgsFeature;
if ( sipCpp->nextFeature( *f ) )
sipRes = sipConvertFromType( f, sipType_QgsFeature, Py_None );
std::unique_ptr< QgsFeature > f = qgis::make_unique< QgsFeature >();
bool result = false;
Py_BEGIN_ALLOW_THREADS
result = ( sipCpp->nextFeature( *f ) );
Py_END_ALLOW_THREADS
if ( result )
sipRes = sipConvertFromType( f.release(), sipType_QgsFeature, Py_None );
else
{
delete f;
PyErr_SetString( PyExc_StopIteration, "" );
}
%End
@@ -276,12 +276,15 @@ class CORE_EXPORT QgsFeatureIterator

SIP_PYOBJECT __next__();
% MethodCode
QgsFeature *f = new QgsFeature;
if ( sipCpp->nextFeature( *f ) )
sipRes = sipConvertFromType( f, sipType_QgsFeature, Py_None );
std::unique_ptr< QgsFeature > f = qgis::make_unique< QgsFeature >();
bool result = false;
Py_BEGIN_ALLOW_THREADS
result = ( sipCpp->nextFeature( *f ) );
Py_END_ALLOW_THREADS
if ( result )
sipRes = sipConvertFromType( f.release(), sipType_QgsFeature, Py_None );
else
{
delete f;
PyErr_SetString( PyExc_StopIteration, "" );
}
% End

0 comments on commit bcbc46b

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