Skip to content

Commit

Permalink
[processing] Fix crash when editing models on Windows (fix #17028)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent 4a974ea commit 6bd37cc
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions python/core/conversions.sip 100644 → 100755
Expand Up @@ -1213,38 +1213,42 @@ template<TYPE2>
if (!d)
return NULL;

const sipMappedType *qlist_type = sipFindMappedType("QList<TYPE2>");

// Set the dictionary elements.
QMap<QString, QList< TYPE2 > >::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() );

PyObject *t2obj = sipConvertFromMappedType(t2, qlist_type, sipTransferObj);
// 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 );
}
}

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;
Expand Down

0 comments on commit 6bd37cc

Please sign in to comment.