@@ -47,6 +47,9 | |||||
47 | #include "PythonQtConversion.h" |
|
47 | #include "PythonQtConversion.h" | |
48 | #include <iostream> |
|
48 | #include <iostream> | |
49 |
|
49 | |||
|
50 | #include <exception> | |||
|
51 | #include <stdexcept> | |||
|
52 | ||||
50 | #define PYTHONQT_MAX_ARGS 32 |
|
53 | #define PYTHONQT_MAX_ARGS 32 | |
51 |
|
54 | |||
52 |
|
55 | |||
@@ -156,25 +159,52 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj | |||||
156 | } |
|
159 | } | |
157 |
|
160 | |||
158 | // invoke the slot via metacall |
|
161 | // invoke the slot via metacall | |
159 | (info->decorator()?info->decorator():objectToCall)->qt_metacall(QMetaObject::InvokeMetaMethod, info->slotIndex(), argList); |
|
162 | bool hadException = false; | |
160 |
|
163 | try { | ||
|
164 | (info->decorator()?info->decorator():objectToCall)->qt_metacall(QMetaObject::InvokeMetaMethod, info->slotIndex(), argList); | |||
|
165 | } catch (std::bad_alloc & e) { | |||
|
166 | hadException = true; | |||
|
167 | QByteArray what("std::bad_alloc: "); | |||
|
168 | what += e.what(); | |||
|
169 | PyErr_SetString(PyExc_MemoryError, what.constData()); | |||
|
170 | } catch (std::runtime_error & e) { | |||
|
171 | hadException = true; | |||
|
172 | QByteArray what("std::runtime_error: "); | |||
|
173 | what += e.what(); | |||
|
174 | PyErr_SetString(PyExc_RuntimeError, what.constData()); | |||
|
175 | } catch (std::logic_error & e) { | |||
|
176 | hadException = true; | |||
|
177 | QByteArray what("std::logic_error: "); | |||
|
178 | what += e.what(); | |||
|
179 | PyErr_SetString(PyExc_RuntimeError, what.constData()); | |||
|
180 | } catch (std::exception& e) { | |||
|
181 | hadException = true; | |||
|
182 | QByteArray what("std::exception: "); | |||
|
183 | what += e.what(); | |||
|
184 | PyErr_SetString(PyExc_StandardError, what.constData()); | |||
|
185 | } | |||
|
186 | ||||
161 |
|
|
187 | if (profilingCB) { | |
162 | profilingCB(PythonQt::Leave, NULL, NULL); |
|
188 | profilingCB(PythonQt::Leave, NULL, NULL); | |
163 | } |
|
189 | } | |
164 |
|
190 | |||
165 | // handle the return value (which in most cases still needs to be converted to a Python object) |
|
191 | // handle the return value (which in most cases still needs to be converted to a Python object) | |
166 | if (argList[0] || returnValueParam.typeId == QMetaType::Void) { |
|
192 | if (!hadException) { | |
167 | if (directReturnValuePointer) { |
|
193 | if (argList[0] || returnValueParam.typeId == QMetaType::Void) { | |
168 | result = NULL; |
|
194 | if (directReturnValuePointer) { | |
169 | } else { |
|
195 | result = NULL; | |
170 | // the resulting object maybe present already, because we created it above at 1)... |
|
196 | } else { | |
171 | if (!result) { |
|
197 | // the resulting object maybe present already, because we created it above at 1)... | |
172 | result = PythonQtConv::ConvertQtValueToPython(returnValueParam, argList[0]); |
|
198 | if (!result) { | |
|
199 | result = PythonQtConv::ConvertQtValueToPython(returnValueParam, argList[0]); | |||
|
200 | } | |||
173 | } |
|
201 | } | |
|
202 | } else { | |||
|
203 | 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."; | |||
|
204 | PyErr_SetString(PyExc_ValueError, e.toLatin1().data()); | |||
|
205 | result = NULL; | |||
174 | } |
|
206 | } | |
175 | } else { |
|
207 | } else { | |
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."; |
|
|||
177 | PyErr_SetString(PyExc_ValueError, e.toLatin1().data()); |
|
|||
178 | result = NULL; |
|
208 | result = NULL; | |
179 | } |
|
209 | } | |
180 | } |
|
210 | } |
General Comments 0
You need to be logged in to leave comments.
Login now