aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2012-07-18 14:17:49 -0400
committerMarcelo Lira <marcelo.lira@openbossa.org>2012-07-31 22:24:28 +0200
commitea6575953822193df672e5fe132f3aa9298e0536 (patch)
tree1e6dbcbc79b5aa7b751a7e04617ec004b7ef19a6 /libpyside
parent1cea6192fa32fee29ae64cdc2bda1414e6a443bd (diff)
During signal emission don't get return type after callback
The callback can disconnect the slot, causing the C++ object for the connection to be deleted. Accessing the return type would then read already freed memory. Change-Id: Ib33fa806978793bcac42167dd45f1e59829a3104 Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/signalmanager.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/libpyside/signalmanager.cpp b/libpyside/signalmanager.cpp
index 81ce14dc0..d9184eba7 100644
--- a/libpyside/signalmanager.cpp
+++ b/libpyside/signalmanager.cpp
@@ -452,22 +452,25 @@ int SignalManager::callPythonMetaMethod(const QMetaMethod& method, void** args,
pyArguments = parseArguments(method.parameterTypes(), args);
if (pyArguments) {
+ Shiboken::Conversions::SpecificConverter* retConverter = NULL;
+ const char* returnType = method.typeName();
+ if (returnType && std::strcmp("", returnType)) {
+ retConverter = new Shiboken::Conversions::SpecificConverter(returnType);
+ if (!retConverter || !*retConverter) {
+ PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s' to call Python meta method.", returnType);
+ PyErr_Print();
+ return -1;
+ }
+ }
+
Shiboken::AutoDecRef retval(PyObject_CallObject(pyMethod, pyArguments));
if (!isShortCuit && pyArguments)
Py_DECREF(pyArguments);
- if (!retval.isNull() && retval != Py_None && !PyErr_Occurred()) {
- const char* returnType = method.typeName();
- if (returnType && std::strcmp("", returnType)) {
- Shiboken::Conversions::SpecificConverter converter(returnType);
- if (converter)
- converter.toCpp(retval, args[0]);
- else
- PyErr_Format(PyExc_RuntimeError, "Can't find converter for '%s' to call Python meta method.", returnType);
-
- }
- }
+ if (!retval.isNull() && retval != Py_None && !PyErr_Occurred() && retConverter)
+ retConverter->toCpp(retval, args[0]);
+ delete retConverter;
}
if (PyErr_Occurred())