@@ -95,7 +95,7 @@ PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet
95
95
listPtr = (QList<void *>*)data;
96
96
}
97
97
if (listPtr) {
98
- return ConvertQListOfPointerTypeToPythonList (listPtr, info. innerName );
98
+ return ConvertQListOfPointerTypeToPythonList (listPtr, info);
99
99
} else {
100
100
return NULL ;
101
101
}
@@ -656,7 +656,7 @@ void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i
656
656
} else {
657
657
ptr = alreadyAllocatedCPPObject;
658
658
}
659
- ok = ConvertPythonListToQListOfPointerType (obj, (QList<void *>*)ptr, info. innerName , strict);
659
+ ok = ConvertPythonListToQListOfPointerType (obj, (QList<void *>*)ptr, info, strict);
660
660
if (ok) {
661
661
return ptr;
662
662
} else {
@@ -1189,7 +1189,7 @@ QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type)
1189
1189
if (info.isQList && (info.innerNamePointerCount == 1 )) {
1190
1190
// allocate a default object of the needed type:
1191
1191
v = QVariant (type, (const void *)NULL );
1192
- ok = ConvertPythonListToQListOfPointerType (val, (QList<void *>*)v.constData (), info. innerName , true );
1192
+ ok = ConvertPythonListToQListOfPointerType (val, (QList<void *>*)v.constData (), info, true );
1193
1193
if (!ok) {
1194
1194
v = QVariant ();
1195
1195
}
@@ -1290,18 +1290,27 @@ PyObject* PythonQtConv::QVariantListToPyObject(const QVariantList& l) {
1290
1290
return result;
1291
1291
}
1292
1292
1293
- PyObject* PythonQtConv::ConvertQListOfPointerTypeToPythonList (QList<void *>* list, const QByteArray& typeName )
1293
+ PyObject* PythonQtConv::ConvertQListOfPointerTypeToPythonList (QList<void *>* list, const PythonQtMethodInfo::ParameterInfo& info )
1294
1294
{
1295
1295
PyObject* result = PyTuple_New (list->count ());
1296
1296
int i = 0 ;
1297
1297
Q_FOREACH (void * value, *list) {
1298
- PyTuple_SET_ITEM (result, i, PythonQt::priv ()->wrapPtr (value, typeName));
1298
+ PyObject* wrap = PythonQt::priv ()->wrapPtr (value, info.innerName );
1299
+ if (wrap) {
1300
+ PythonQtInstanceWrapper* wrapper = (PythonQtInstanceWrapper*)wrap;
1301
+ if (info.passOwnershipToCPP ) {
1302
+ wrapper->passOwnershipToCPP ();
1303
+ } else if (info.passOwnershipToPython ) {
1304
+ wrapper->passOwnershipToPython ();
1305
+ }
1306
+ }
1307
+ PyTuple_SET_ITEM (result, i, wrap);
1299
1308
i++;
1300
1309
}
1301
1310
return result;
1302
1311
}
1303
1312
1304
- bool PythonQtConv::ConvertPythonListToQListOfPointerType (PyObject* obj, QList<void *>* list, const QByteArray& type , bool /* strict*/ )
1313
+ bool PythonQtConv::ConvertPythonListToQListOfPointerType (PyObject* obj, QList<void *>* list, const PythonQtMethodInfo::ParameterInfo& info , bool /* strict*/ )
1305
1314
{
1306
1315
bool result = false ;
1307
1316
if (PySequence_Check (obj)) {
@@ -1314,9 +1323,16 @@ bool PythonQtConv::ConvertPythonListToQListOfPointerType(PyObject* obj, QList<vo
1314
1323
if (PyObject_TypeCheck (value, &PythonQtInstanceWrapper_Type)) {
1315
1324
PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)value;
1316
1325
bool ok;
1317
- void * object = castWrapperTo (wrap, type , ok);
1326
+ void * object = castWrapperTo (wrap, info. innerName , ok);
1318
1327
Py_XDECREF (value);
1319
1328
if (ok) {
1329
+ if (object) {
1330
+ if (info.passOwnershipToCPP ) {
1331
+ wrap->passOwnershipToCPP ();
1332
+ } else if (info.passOwnershipToPython ) {
1333
+ wrap->passOwnershipToPython ();
1334
+ }
1335
+ }
1320
1336
list->append (object);
1321
1337
} else {
1322
1338
result = false ;
0 commit comments