Implemented support to connection type.

Reviewer: Hugo Parente Lima <hugo.lima@openbossa.org>,
          Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
Renato Filho 2010-05-17 18:56:00 -03:00
commit 3f6c11762e
2 changed files with 14 additions and 3 deletions

View file

@ -348,9 +348,9 @@ void signal_instance_initialize(PyObject* instance, PyObject* name, SignalData*
PyObject* signal_instance_connect(PyObject* self, PyObject* args, PyObject* kwds) PyObject* signal_instance_connect(PyObject* self, PyObject* args, PyObject* kwds)
{ {
PyObject *slot; PyObject *slot = 0;
PyObject *type; PyObject *type = 0;
static const char *kwlist[] = {"type", 0}; static const char *kwlist[] = {"slot", "type", 0};
if (!PyArg_ParseTupleAndKeywords(args, kwds, if (!PyArg_ParseTupleAndKeywords(args, kwds,
"O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type)) "O|O:"SIGNAL_CLASS_NAME, (char**) kwlist, &slot, &type))
@ -384,6 +384,9 @@ PyObject* signal_instance_connect(PyObject* self, PyObject* args, PyObject* kwds
match = true; match = true;
} }
if (type)
PyList_Append(pyArgs, type);
if (match) { if (match) {
Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs)); Shiboken::AutoDecRef tupleArgs(PyList_AsTuple(pyArgs));
Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "connect")); Shiboken::AutoDecRef pyMethod(PyObject_GetAttrString(source->source, "connect"));

View file

@ -60,5 +60,13 @@ class SignalObjectTest(UsesQCoreApplication):
self.app.exec_() self.app.exec_()
self.assert_(self._cb_called) self.assert_(self._cb_called)
def testConnectionType(self):
o = MyObject()
o.timeout.connect(self.cb, type=Qt.DirectConnection)
o.start(100)
self.app.exec_()
self.assert_(self._cb_called)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()