diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-02-16 16:07:01 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-02-16 16:07:01 -0200 |
commit | e0cf4b000d1363b9cbeab707364e8e1933f4ee92 (patch) | |
tree | be3d21ad80d14f38fd6a9a9763bab813355e4b44 | |
parent | adfaf21063d4d996ee0c3e28b5c41999209a93f9 (diff) | |
download | pyside-e0cf4b000d1363b9cbeab707364e8e1933f4ee92.tar.gz pyside-e0cf4b000d1363b9cbeab707364e8e1933f4ee92.tar.xz pyside-e0cf4b000d1363b9cbeab707364e8e1933f4ee92.zip |
Fix bug 674 - "QGraphicsScene::clear() is missing"
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 16 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/bug_674.py | 23 |
3 files changed, 39 insertions, 1 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index b7b2873..724ac1e 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -3099,7 +3099,21 @@ <modify-function signature="createItemGroup(const QList<QGraphicsItem*>&)" remove="all"/> <modify-function signature="destroyItemGroup(QGraphicsItemGroup*)" remove="all"/> - <modify-function signature="clear()" remove="all"/> + <modify-function signature="clear()"> + <inject-code> + const QList<QGraphicsItem*> items = %CPPSELF.items(); + Shiboken::BindingManager& bm = Shiboken::BindingManager::instance(); + foreach (QGraphicsItem* item, items) { + SbkObject* obj = bm.retrieveWrapper(item); + if (obj) { + if (obj->ob_refcnt > 1) // If the refcnt is 1 the object will vannish anyway. + Shiboken::Object::invalidate(obj); + Shiboken::Object::removeParent(obj); + } + } + %CPPSELF.%FUNCTION_NAME(); + </inject-code> + </modify-function> <modify-function signature="removeItem(QGraphicsItem*)"> <modify-argument index="1"> diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index 1c10e5c..3897532 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -39,6 +39,7 @@ PYSIDE_TEST(bug_660.py) PYSIDE_TEST(bug_662.py) PYSIDE_TEST(bug_667.py) PYSIDE_TEST(bug_668.py) +PYSIDE_TEST(bug_674.py) PYSIDE_TEST(bug_675.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(deepcopy_test.py) diff --git a/tests/QtGui/bug_674.py b/tests/QtGui/bug_674.py new file mode 100644 index 0000000..4d015b5 --- /dev/null +++ b/tests/QtGui/bug_674.py @@ -0,0 +1,23 @@ +from PySide.QtCore import * +from PySide.QtGui import * +import unittest +import sys + +class TestBug679(unittest.TestCase): + '''QGraphicsScene::clear() is missing''' + def testIt(self): + app = QApplication([]) + + scene = QGraphicsScene() + hello = scene.addText("Hello") + scene.addText("World") + + self.assertEqual(sys.getrefcount(hello), 3) + scene.clear() + self.assertEqual(sys.getrefcount(hello), 2) + self.assertEqual(len(scene.items()), 0) + self.assertRaises(RuntimeError, hello.isVisible) # the C++ object was deleted + +if __name__ == '__main__': + unittest.main() + |