[PyQt] Leak in MappedType code?

Nyall Dawson nyall.dawson at gmail.com
Sun Jan 28 08:20:40 GMT 2018


Hi list,

I'm seeing a leak when using the MappedType code for a class based on
QVector< QVariant >. The code in question is almost an exact copy of
the PyQt QVector code:

%ConvertFromTypeCode
  // Create the list.
  PyObject *l;

  if ( ( l = PyList_New( sipCpp->size() ) ) == NULL )
    return NULL;

  // Set the list elements.
  for ( int i = 0; i < sipCpp->size(); ++i )
  {
    QVariant *v = new QVariant( sipCpp->at( i ) );
    PyObject *tobj;

    if ( ( tobj = sipConvertFromNewType( v, sipType_QVariant,
sipTransferObj ) ) == NULL )
    {
      Py_DECREF( l );
      delete v;

      return NULL;
    }

    PyList_SET_ITEM( l, i, tobj );
  }

  return l;
%End

Using sip 4.19.5, Qt 5.9.2 and Python 3.6.3 I see a leak with this
code - yet with the exact same code on Qt 4.7 and Python 2.7.14 I see
no leak.

Any idea what's happening here?

Nyall


More information about the PyQt mailing list