diff --git a/python/core/conversions.sip b/python/core/conversions.sip old mode 100644 new mode 100755 index 5a1250c0957..1cd77fa22a0 --- a/python/core/conversions.sip +++ b/python/core/conversions.sip @@ -1213,38 +1213,42 @@ template if (!d) return NULL; - const sipMappedType *qlist_type = sipFindMappedType("QList"); - // Set the dictionary elements. QMap >::const_iterator i; for (i = sipCpp->constBegin(); i != sipCpp->constEnd(); ++i) { QString *t1 = new QString(i.key()); - PyObject *t1obj = sipConvertFromNewType(t1, sipType_QString, sipTransferObj); - QList< TYPE2 > *t2 = new QList< TYPE2 >( i.value() ); + // build list for dictionary value + QList< TYPE2 > sourceList = i.value(); + PyObject *t2list = PyList_New( sourceList.size() ); + if ( t2list ) + { + for ( int j = 0; j < sourceList.size(); j++ ) + { + TYPE2 *t = new TYPE2(sourceList.at(j)); + PyObject *lobj = sipConvertFromNewType(t, sipType_TYPE2, sipTransferObj); + PyList_SetItem( t2list, j, lobj ); + } + } - PyObject *t2obj = sipConvertFromMappedType(t2, qlist_type, sipTransferObj); - - if (t1obj == NULL || t2obj == NULL || PyDict_SetItem(d, t1obj, t2obj) < 0) + if (t1obj == NULL || t2list == NULL || PyDict_SetItem(d, t1obj, t2list) < 0) { Py_DECREF(d); if (t1obj) Py_DECREF(t1obj); - if (t2obj) - Py_DECREF(t2obj); - else - delete t2; + if (t2list) + Py_DECREF(t2list); return NULL; } Py_DECREF(t1obj); - Py_DECREF(t2obj); + Py_DECREF(t2list); } return d;