summaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-08-26 19:11:54 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-08-29 18:44:07 -0300
commite3d93bcb06885aebee693f0357a131c6880f563c (patch)
tree7d00a1140c202cb5f8470211bef3bdf73cad2b7a /libpyside
parentfe821e16f8c76ed9251377734e81c92c9edebaaf (diff)
downloadpyside-e3d93bcb06885aebee693f0357a131c6880f563c.tar.gz
pyside-e3d93bcb06885aebee693f0357a131c6880f563c.tar.xz
pyside-e3d93bcb06885aebee693f0357a131c6880f563c.zip
Fail during the signal connection or disconnection raises exception.
Fixes bug #987. Reviewed by: Hugo Parente <hugo.lima@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/pysidesignal.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/libpyside/pysidesignal.cpp b/libpyside/pysidesignal.cpp
index 7fdb01f..b4940d5 100644
--- a/libpyside/pysidesignal.cpp
+++ b/libpyside/pysidesignal.cpp
@@ -374,9 +374,14 @@ PyObject* signalInstanceConnect(PyObject* self, PyObject* args, PyObject* kwds)
if (match) {
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "connect"));
- return PyObject_CallObject(pyMethod, tupleArgs);
+ PyObject* result = PyObject_CallObject(pyMethod, tupleArgs);
+ if (result == Py_True)
+ return result;
+ else
+ Py_DECREF(result);
}
+ PyErr_Format(PyExc_RuntimeError, "Fail to connect signal %s.", source->d->signature);
return 0;
}
@@ -416,7 +421,6 @@ PyObject* signalInstanceGetItem(PyObject* self, PyObject* key)
}
PyErr_Format(PyExc_IndexError, "Signature %s not found for signal: %s", sig, sigName);
free(sig);
-
return 0;
}
@@ -460,9 +464,14 @@ PyObject* signalInstanceDisconnect(PyObject* self, PyObject* args)
if (match) {
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->d->source, "disconnect"));
- return PyObject_CallObject(pyMethod, tupleArgs);
+ PyObject* result = PyObject_CallObject(pyMethod, tupleArgs);
+ if (result == Py_True)
+ return result;
+ else
+ Py_DECREF(result);
}
+ PyErr_Format(PyExc_RuntimeError, "Fail to disconnect signal %s.", source->d->signature);
return 0;
}
@@ -674,7 +683,13 @@ bool connect(PyObject* source, const char* signal, PyObject* callback)
Shiboken::AutoDecRef pySignature(PyString_FromString(signal));
Shiboken::AutoDecRef pyArgs(PyTuple_Pack(3, source, pySignature.object(), callback));
- return PyObject_CallObject(pyMethod, pyArgs);
+ PyObject* result = PyObject_CallObject(pyMethod, pyArgs);
+ if (result == Py_False) {
+ PyErr_Format(PyExc_RuntimeError, "Fail to connect signal %s, to python callable object.", signal);
+ Py_DECREF(result);
+ result = 0;
+ }
+ return result;
}
PySideSignalInstance* newObjectFromMethod(PyObject* source, const QList<QMetaMethod>& methodList)