Skip to content

Commit f0a6d6a

Browse files
committed
fixed direct calls with void return value, as used when py_set_ slots are called
1 parent 4ed1667 commit f0a6d6a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/PythonQtSlot.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
8080
const QList<PythonQtSlotInfo::ParameterInfo>& params = info->parameters();
8181

8282
const PythonQtSlotInfo::ParameterInfo& returnValueParam = params.at(0);
83+
bool isVoidReturnValue = (returnValueParam.typeId == QMetaType::Void);
84+
8385
// set return argument to NULL
8486
argList[0] = NULL;
8587

@@ -133,7 +135,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
133135
}
134136

135137
// parameters are ok, now create the qt return value which is assigned to by metacall
136-
if (returnValueParam.typeId != QMetaType::Void) {
138+
if (!isVoidReturnValue) {
137139
// create empty default value for the return value
138140
if (!directReturnValuePointer) {
139141
// create empty default value for the return value
@@ -219,7 +221,7 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
219221

220222
// handle the return value (which in most cases still needs to be converted to a Python object)
221223
if (!hadException) {
222-
if (argList[0] || returnValueParam.typeId == QMetaType::Void) {
224+
if (argList[0] || isVoidReturnValue) {
223225
if (directReturnValuePointer) {
224226
result = NULL;
225227
} else {
@@ -232,9 +234,11 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
232234
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.";
233235
PyErr_SetString(PyExc_ValueError, e.toLatin1().data());
234236
result = NULL;
237+
ok = false;
235238
}
236239
} else {
237240
result = NULL;
241+
ok = false;
238242
}
239243
}
240244
recursiveEntry--;
@@ -255,8 +259,11 @@ bool PythonQtCallSlot(PythonQtClassInfo* classInfo, QObject* objectToCall, PyObj
255259
}
256260
// NOTE: a return value can not pass the ownership to CPP, it would not make sense...
257261
}
262+
// Either we have a
263+
// a) a result value
264+
// b) a directReturnValuePointer and it has a value or the return value is void
258265
// NOTE: it is important to only return here, otherwise the stack will not be popped!!!
259-
return result || (directReturnValuePointer && *directReturnValuePointer);
266+
return ok && (result || (directReturnValuePointer && (*directReturnValuePointer || isVoidReturnValue)));
260267
}
261268

262269
//-----------------------------------------------------------------------------------

0 commit comments

Comments
 (0)