@@ -76,7 +76,13 PyObject* PythonQtConv::ConvertQtValueToPython(const PythonQtMethodInfo::Paramet | |||||
76 | return Py_None; |
|
76 | return Py_None; | |
77 | } else if ((info.pointerCount == 1) && (info.typeId == QMetaType::Char)) { |
|
77 | } else if ((info.pointerCount == 1) && (info.typeId == QMetaType::Char)) { | |
78 | // a char ptr will probably be a null terminated string, so we support that: |
|
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 | } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) && |
|
86 | } else if ((info.typeId == PythonQtMethodInfo::Unknown || info.typeId >= QMetaType::User) && | |
81 | info.name.startsWith("QList<")) { |
|
87 | info.name.startsWith("QList<")) { | |
82 | // it is a QList template: |
|
88 | // it is a QList template: | |
@@ -371,7 +377,11 void* PythonQtConv::ConvertPythonToQt(const PythonQtMethodInfo::ParameterInfo& i | |||||
371 | ptr = object; |
|
377 | ptr = object; | |
372 | } |
|
378 | } | |
373 | } else { |
|
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 | } else if (info.pointerCount == 1) { |
|
386 | } else if (info.pointerCount == 1) { | |
377 | // a pointer |
|
387 | // a pointer | |
@@ -885,14 +895,14 QVariant PythonQtConv::PyObjToQVariant(PyObject* val, int type) | |||||
885 | // no special type requested |
|
895 | // no special type requested | |
886 | if (val->ob_type==&PyString_Type || val->ob_type==&PyUnicode_Type) { |
|
896 | if (val->ob_type==&PyString_Type || val->ob_type==&PyUnicode_Type) { | |
887 | type = QVariant::String; |
|
897 | type = QVariant::String; | |
|
898 | } else if (val == Py_False || val == Py_True) { | |||
|
899 | type = QVariant::Bool; | |||
888 | } else if (PyObject_TypeCheck(val, &PyInt_Type)) { |
|
900 | } else if (PyObject_TypeCheck(val, &PyInt_Type)) { | |
889 | type = QVariant::Int; |
|
901 | type = QVariant::Int; | |
890 | } else if (val->ob_type==&PyLong_Type) { |
|
902 | } else if (val->ob_type==&PyLong_Type) { | |
891 | type = QVariant::LongLong; |
|
903 | type = QVariant::LongLong; | |
892 | } else if (val->ob_type==&PyFloat_Type) { |
|
904 | } else if (val->ob_type==&PyFloat_Type) { | |
893 | type = QVariant::Double; |
|
905 | type = QVariant::Double; | |
894 | } else if (val == Py_False || val == Py_True) { |
|
|||
895 | type = QVariant::Bool; |
|
|||
896 | } else if (PyObject_TypeCheck(val, &PythonQtInstanceWrapper_Type)) { |
|
906 | } else if (PyObject_TypeCheck(val, &PythonQtInstanceWrapper_Type)) { | |
897 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; |
|
907 | PythonQtInstanceWrapper* wrap = (PythonQtInstanceWrapper*)val; | |
898 | // c++ wrapper, check if the class names of the c++ objects match |
|
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