From 75b44379d3e9e5f6dc4e6943b2f2229e32802892 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Thu, 16 Sep 2010 16:47:30 -0300 Subject: Added the method signature QTimer.singleShot(int, Signal). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes bug #313. The implementation can be improved when bug #362 gets fixed. Reviewed by Luciano Wolf Reviewed by Renato Araújo --- PySide/QtCore/typesystem_core.xml | 52 +++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'PySide') diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index c0b333ff4..d7c5891a7 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -1726,8 +1726,15 @@ Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); - PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsOs"), pyTimer, SIGNAL(timeout()), %PYARG_2, %3); - Py_DECREF(result); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOs"), + pyTimer, + SIGNAL(timeout()), + %PYARG_2, + %3) + ); // invalidate to avoid use of python object Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer); timer->setSingleShot(true); @@ -1744,10 +1751,45 @@ QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); timer->setSingleShot(true); timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); - PyObject* result = PyObject_CallMethod(pyTimer, const_cast<char*>("connect"), const_cast<char*>("OsO"), pyTimer, SIGNAL(timeout()), pyargs[1]); - Py_DECREF(result); + + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsO"), + pyTimer, + SIGNAL(timeout()), + pyargs[1]) + ); + Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer); + timer->start(%1); + + + + + + if (!PyObject_TypeCheck(%2, &PySide::SignalInstance_Type)) + goto Sbk%TYPEFunc_%FUNCTION_NAME_TypeError; + + // %FUNCTION_NAME() - disable generation of c++ function call + Shiboken::AutoDecRef emptyTuple(PyTuple_New(0)); + PyObject* pyTimer = Shiboken::SbkType<QTimer>()->tp_new(Shiboken::SbkType<QTimer>(), emptyTuple, 0); + Shiboken::SbkType<QTimer>()->tp_init(pyTimer, emptyTuple, 0); + QTimer* timer = Converter<QTimer*>::toCpp(pyTimer); + timer->setSingleShot(true); + timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater())); + PySide::SignalInstanceData* signalInstance = reinterpret_cast<PySide::SignalInstanceData*>(%2); + Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", signalInstance->signature)); + Shiboken::AutoDecRef result( + PyObject_CallMethod(pyTimer, + const_cast<char*>("connect"), + const_cast<char*>("OsOO"), + pyTimer, + SIGNAL(timeout()), + signalInstance->source, + signalSignature.object()) + ); Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer); - timer->start(cpp_arg0); + timer->start(%1); -- cgit v1.2.3