@@ -47,6 +47,9 | |||
|
47 | 47 | #include "PythonQtConversion.h" |
|
48 | 48 | #include <iostream> |
|
49 | 49 | |
|
50 | #include <exception> | |
|
51 | #include <stdexcept> | |
|
52 | ||
|
50 | 53 | #define PYTHONQT_MAX_ARGS 32 |
|
51 | 54 | |
|
52 | 55 | |
@@ -156,13 +159,37 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj | |||
|
156 | 159 | } |
|
157 | 160 | |
|
158 | 161 | // invoke the slot via metacall |
|
162 | bool hadException = false; | |
|
163 | try { | |
|
159 | 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 | } | |
|
160 | 186 | |
|
161 | 187 |
|
|
162 | 188 | profilingCB(PythonQt::Leave, NULL, NULL); |
|
163 | 189 | } |
|
164 | 190 | |
|
165 | 191 | // handle the return value (which in most cases still needs to be converted to a Python object) |
|
192 | if (!hadException) { | |
|
166 | 193 | if (argList[0] || returnValueParam.typeId == QMetaType::Void) { |
|
167 | 194 | if (directReturnValuePointer) { |
|
168 | 195 | result = NULL; |
@@ -177,6 +204,9 bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj | |||
|
177 | 204 | PyErr_SetString(PyExc_ValueError, e.toLatin1().data()); |
|
178 | 205 | result = NULL; |
|
179 | 206 | } |
|
207 | } else { | |
|
208 | result = NULL; | |
|
209 | } | |
|
180 | 210 | } |
|
181 | 211 | recursiveEntry--; |
|
182 | 212 |
General Comments 0
You need to be logged in to leave comments.
Login now