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> | 2012-03-08 16:53:59 -0300 |
commit | 8550948818153625a4f23def6eb2ab1b7e63d30b (patch) | |
tree | a30ead73141d2842e24d243fe2e79c177b21d3f2 | |
parent | c8ecf9fea606679be567b9799fd6afb40a370564 (diff) |
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 b7b28734a..724ac1eca 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 1c10e5c3a..38975321a 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 000000000..4d015b577 --- /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() + |