@@ -76,7 +76,13 PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet | |||
|
76 | 76 | return Py_None; |
|
77 | 77 | } else if ((info.pointerCount == 1) && (info.typeId == QMetaType::Char)) { |
|
78 | 78 | // a char ptr will probably be a null terminated string, so we support that: |
|
79 | return PyString_FromString(*((char**)data)); | |
|
79 | char* charPtr = *((char**)data); | |
|
80 | if (charPtr) { | |
|
81 | return PyString_FromString(charPtr); | |
|
82 | } else { | |
|
83 | Py_INCREF(Py_None); | |
|
84 | return Py_None; | |
|
85 | } | |
|
80 | 86 | } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) && |
|
81 | 87 | info.name.startsWith("QList<")) { |
|
82 | 88 | // it is a QList template: |
@@ -371,7 +377,11 void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i | |||
|
371 | 377 | ptr = object; |
|
372 | 378 | } |
|
373 | 379 | } else { |
|
374 | // not matching | |
|
380 | // not matching, maybe a PyObject*? | |
|
381 | if (info.name == "PyObject" && info.pointerCount==1) { | |
|
382 | // handle low level PyObject directly | |
|
383 | PythonQtValueStorage_ADD_VALUE_IF_NEEDED(alreadyAllocatedCPPObject,global_ptrStorage, void*, obj, ptr); | |
|
384 | } | |
|
375 | 385 | } |
|
376 | 386 | } else if (info.pointerCount == 1) { |
|
377 | 387 | // a pointer |
@@ -885,14 +895,14 QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) | |||
|
885 | 895 | // no special type requested |
|
886 | 896 | if (val->ob_type==&PyString_Type || val->ob_type==&PyUnicode_Type) { |
|
887 | 897 | type = QVariant::String; |
|
898 | } else if (val == Py_False || val == Py_True) { | |
|
899 | type = QVariant::Bool; | |
|
888 | 900 | } else if (PyObject_TypeCheck(val, &PyInt_Type)) { |
|
889 | 901 | type = QVariant::Int; |
|
890 | 902 | } else if (val->ob_type==&PyLong_Type) { |
|
891 | 903 | type = QVariant::LongLong; |
|
892 | 904 | } else if (val->ob_type==&PyFloat_Type) { |
|
893 | 905 | type = QVariant::Double; |
|
894 | } else if (val == Py_False || val == Py_True) { | |
|
895 | type = QVariant::Bool; | |
|
896 | 906 | } else if (PyObject_TypeCheck(val, &PythonQtInstanceWrapper_Type)) { |
|
897 | 907 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; |
|
898 | 908 | // c++ wrapper, check if the class names of the c++ objects match |
General Comments 0
You need to be logged in to leave comments.
Login now