mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Fix possible GIL deadlock when iterating features in python
and an exception is thrown
This commit is contained in:
parent
285bb0631b
commit
bcbc46b56b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user