@@ -134,6 +134,20 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj | |||||
134 | if (!directReturnValuePointer) { |
|
134 | if (!directReturnValuePointer) { | |
135 | // create empty default value for the return value |
|
135 | // create empty default value for the return value | |
136 | argList[0] = PythonQtConv::CreateQtReturnValue(returnValueParam); |
|
136 | argList[0] = PythonQtConv::CreateQtReturnValue(returnValueParam); | |
|
137 | if (argList[0]==NULL) { | |||
|
138 | // return value could not be created, maybe we have a registered class with a default constructor, so that we can construct the pythonqt wrapper object and | |||
|
139 | // pass its internal pointer | |||
|
140 | PythonQtClassInfo* info = PythonQt::priv()->getClassInfo(returnValueParam.name); | |||
|
141 | if (info && info->pythonQtClassWrapper()) { | |||
|
142 | PyObject* emptyTuple = PyTuple_New(0); | |||
|
143 | // 1) default construct an empty object as python object (owned by PythonQt), by calling the meta class with empty arguments | |||
|
144 | result = PyObject_Call((PyObject*)info->pythonQtClassWrapper(), emptyTuple, NULL); | |||
|
145 | if (result) { | |||
|
146 | argList[0] = ((PythonQtInstanceWrapper*)result)->_wrappedPtr; | |||
|
147 | } | |||
|
148 | Py_DECREF(emptyTuple); | |||
|
149 | } | |||
|
150 | } | |||
137 | } else { |
|
151 | } else { | |
138 | // we can use our pointer directly! |
|
152 | // we can use our pointer directly! | |
139 | argList[0] = directReturnValuePointer; |
|
153 | argList[0] = directReturnValuePointer; | |
@@ -150,13 +164,16 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj | |||||
150 | result = NULL; |
|
164 | result = NULL; | |
151 | } else { |
|
165 | } else { | |
152 | if (!returnValueIsEnum) { |
|
166 | if (!returnValueIsEnum) { | |
153 | result = PythonQtConv::ConvertQtValueToPython(returnValueParam, argList[0]); |
|
167 | // the resulting object maybe present already, because we created it above at 1)... | |
|
168 | if (!result) { | |||
|
169 | result = PythonQtConv::ConvertQtValueToPython(returnValueParam, argList[0]); | |||
|
170 | } | |||
154 | } else { |
|
171 | } else { | |
155 | result = PyInt_FromLong(*((unsigned int*)argList[0])); |
|
172 | result = PyInt_FromLong(*((unsigned int*)argList[0])); | |
156 | } |
|
173 | } | |
157 | } |
|
174 | } | |
158 | } else { |
|
175 | } else { | |
159 | QString e = QString("Called ") + info->fullSignature() + ", return type '" + returnValueParam.name + "' is ignored because it is unknown to PythonQt. Probaby you should register it using qRegisterMetaType()."; |
|
176 | QString e = QString("Called ") + info->fullSignature() + ", return type '" + returnValueParam.name + "' is ignored because it is unknown to PythonQt. Probably you should register it using qRegisterMetaType() or add a default constructor decorator to the class."; | |
160 | PyErr_SetString(PyExc_ValueError, e.toLatin1().data()); |
|
177 | PyErr_SetString(PyExc_ValueError, e.toLatin1().data()); | |
161 | result = NULL; |
|
178 | result = NULL; | |
162 | } |
|
179 | } |
General Comments 0
You need to be logged in to leave comments.
Login now