Fix bug#256 - "PySide does not support signals with containers."
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
ee00f28629
commit
b812f04d24
3 changed files with 39 additions and 0 deletions
|
|
@ -67,6 +67,7 @@ struct QtDictConverter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<QtDict*>(cppObj)); }
|
||||||
static inline PyObject* toPython(const QtDict& cppobj)
|
static inline PyObject* toPython(const QtDict& cppobj)
|
||||||
{
|
{
|
||||||
PyObject* result = PyDict_New();
|
PyObject* result = PyDict_New();
|
||||||
|
|
@ -133,6 +134,7 @@ struct QtMultiMapConverter
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<MultiMap*>(cppObj)); }
|
||||||
static inline PyObject* toPython(const MultiMap& cppObj)
|
static inline PyObject* toPython(const MultiMap& cppObj)
|
||||||
{
|
{
|
||||||
PyObject* result = PyDict_New();
|
PyObject* result = PyDict_New();
|
||||||
|
|
@ -194,6 +196,7 @@ struct QSequenceConverter
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
static inline PyObject* toPython(void* cppObj) { return toPython(*reinterpret_cast<T*>(cppObj)); }
|
||||||
static PyObject* toPython(const T& cppobj)
|
static PyObject* toPython(const T& cppobj)
|
||||||
{
|
{
|
||||||
PyObject* result = PyList_New((int) cppobj.size());
|
PyObject* result = PyList_New((int) cppobj.size());
|
||||||
|
|
|
||||||
|
|
@ -30,3 +30,4 @@ PYSIDE_TEST(signal_with_primitive_type_test.py)
|
||||||
PYSIDE_TEST(slot_reference_count_test.py)
|
PYSIDE_TEST(slot_reference_count_test.py)
|
||||||
PYSIDE_TEST(static_metaobject_test.py)
|
PYSIDE_TEST(static_metaobject_test.py)
|
||||||
PYSIDE_TEST(upstream_segfault_test.py)
|
PYSIDE_TEST(upstream_segfault_test.py)
|
||||||
|
PYSIDE_TEST(list_signal_test.py)
|
||||||
|
|
|
||||||
35
tests/signals/list_signal_test.py
Normal file
35
tests/signals/list_signal_test.py
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from PySide.QtCore import *
|
||||||
|
from PySide.QtGui import *
|
||||||
|
|
||||||
|
class ListConnectionTest(unittest.TestCase):
|
||||||
|
|
||||||
|
def modifyScene(self):
|
||||||
|
self.scene.addLine(0, 0, 10, 10)
|
||||||
|
|
||||||
|
def sceneChanged(self, rects):
|
||||||
|
# Qt isn't so cute and sends this signal with empty lists and null rects sometimes.
|
||||||
|
if len(rects) > 0 and not rects[0].isNull():
|
||||||
|
self.rects = rects
|
||||||
|
QApplication.quit()
|
||||||
|
|
||||||
|
def testConnection(self):
|
||||||
|
app = QApplication([])
|
||||||
|
|
||||||
|
self.scene = QGraphicsScene()
|
||||||
|
QTimer.singleShot(0, self.modifyScene)
|
||||||
|
self.scene.changed.connect(self.sceneChanged)
|
||||||
|
|
||||||
|
app.exec_()
|
||||||
|
self.assertEquals(len(self.rects), 1)
|
||||||
|
self.assertEquals(self.rects[0].x(), 0)
|
||||||
|
self.assertEquals(self.rects[0].y(), 0)
|
||||||
|
self.assertEquals(self.rects[0].width(), 10)
|
||||||
|
self.assertEquals(self.rects[0].height(), 10)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue