Fix bug 674 - "QGraphicsScene::clear() is missing"
This commit is contained in:
parent
c8ecf9fea6
commit
8550948818
3 changed files with 39 additions and 1 deletions
|
|
@ -3099,7 +3099,21 @@
|
||||||
|
|
||||||
<modify-function signature="createItemGroup(const QList<QGraphicsItem*>&)" remove="all"/>
|
<modify-function signature="createItemGroup(const QList<QGraphicsItem*>&)" remove="all"/>
|
||||||
<modify-function signature="destroyItemGroup(QGraphicsItemGroup*)" 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-function signature="removeItem(QGraphicsItem*)">
|
||||||
<modify-argument index="1">
|
<modify-argument index="1">
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ PYSIDE_TEST(bug_660.py)
|
||||||
PYSIDE_TEST(bug_662.py)
|
PYSIDE_TEST(bug_662.py)
|
||||||
PYSIDE_TEST(bug_667.py)
|
PYSIDE_TEST(bug_667.py)
|
||||||
PYSIDE_TEST(bug_668.py)
|
PYSIDE_TEST(bug_668.py)
|
||||||
|
PYSIDE_TEST(bug_674.py)
|
||||||
PYSIDE_TEST(bug_675.py)
|
PYSIDE_TEST(bug_675.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
|
|
|
||||||
23
tests/QtGui/bug_674.py
Normal file
23
tests/QtGui/bug_674.py
Normal file
|
|
@ -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()
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue