aboutsummaryrefslogtreecommitdiffstats
path: root/PySide
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-09-16 16:47:30 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-09-17 08:54:46 -0300
commit75b44379d3e9e5f6dc4e6943b2f2229e32802892 (patch)
tree8786a21f59994d8d96e43db30898f4d2d7c61316 /PySide
parent562bb8a822a8ef24066d75b613d9c2d05fb2fdee (diff)
Added the method signature QTimer.singleShot(int, Signal).
This fixes bug #313. The implementation can be improved when bug #362 gets fixed. Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'PySide')
-rw-r--r--PySide/QtCore/typesystem_core.xml52
1 files changed, 47 insertions, 5 deletions
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&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
QTimer* timer = Converter&lt;QTimer*>::toCpp(pyTimer);
- PyObject* result = PyObject_CallMethod(pyTimer, const_cast&lt;char*>("connect"), const_cast&lt;char*>("OsOs"), pyTimer, SIGNAL(timeout()), %PYARG_2, %3);
- Py_DECREF(result);
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;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&lt;QTimer*>::toCpp(pyTimer);
timer->setSingleShot(true);
timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
- PyObject* result = PyObject_CallMethod(pyTimer, const_cast&lt;char*>("connect"), const_cast&lt;char*>("OsO"), pyTimer, SIGNAL(timeout()), pyargs[1]);
- Py_DECREF(result);
+
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;char*>("OsO"),
+ pyTimer,
+ SIGNAL(timeout()),
+ pyargs[1])
+ );
+ Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer);
+ timer->start(%1);
+ </inject-code>
+ </add-function>
+ <!-- Second argument is a PySide.QtCore.Signal. See bug #362. -->
+ <add-function signature="singleShot(int, PyObject*)" static="yes">
+ <inject-code class="target" position="beginning">
+ if (!PyObject_TypeCheck(%2, &amp;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&lt;QTimer>()->tp_new(Shiboken::SbkType&lt;QTimer>(), emptyTuple, 0);
+ Shiboken::SbkType&lt;QTimer>()->tp_init(pyTimer, emptyTuple, 0);
+ QTimer* timer = Converter&lt;QTimer*>::toCpp(pyTimer);
+ timer->setSingleShot(true);
+ timer->connect(timer, SIGNAL(timeout()), timer, SLOT(deleteLater()));
+ PySide::SignalInstanceData* signalInstance = reinterpret_cast&lt;PySide::SignalInstanceData*&gt;(%2);
+ Shiboken::AutoDecRef signalSignature(PyString_FromFormat("2%s", signalInstance->signature));
+ Shiboken::AutoDecRef result(
+ PyObject_CallMethod(pyTimer,
+ const_cast&lt;char*>("connect"),
+ const_cast&lt;char*>("OsOO"),
+ pyTimer,
+ SIGNAL(timeout()),
+ signalInstance->source,
+ signalSignature.object())
+ );
Shiboken::BindingManager::instance().invalidateWrapper((Shiboken::SbkBaseWrapper *)pyTimer);
- timer->start(cpp_arg0);
+ timer->start(%1);
</inject-code>
</add-function>
</object-type>