summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-12-27 18:59:32 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2010-12-27 19:20:05 -0300
commita74d92adcecb3df3bbb712e67590052279c5fd06 (patch)
tree0fe4bd66065b6946743880abad26670e75bdf05e
parent656be4ec981d793205e4818b1352a2b3896d9196 (diff)
downloadpyside-a74d92adcecb3df3bbb712e67590052279c5fd06.tar.gz
pyside-a74d92adcecb3df3bbb712e67590052279c5fd06.tar.xz
pyside-a74d92adcecb3df3bbb712e67590052279c5fd06.zip
Fix QTreeWidget parent rules.
QTreeWidget.clear() - remove all child ref from the current widget QTreeWidgetItem.parent() - use default policy for returned value Fix bug #547 Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml20
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_547.py39
3 files changed, 60 insertions, 0 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 0994331..c2b6343 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -3030,6 +3030,18 @@
<parent index="this" action="remove"/>
</modify-argument>
</modify-function>
+ <modify-function signature="clear()">
+ <inject-code>
+ QTreeWidgetItem *rootItem = %CPPSELF.invisibleRootItem();
+ Shiboken::BindingManager &amp;bm = Shiboken::BindingManager::instance();
+ for (int i = 0; i &lt; rootItem->childCount(); ++i) {
+ QTreeWidgetItem *item = rootItem->child(i);
+ SbkObject* wrapper = bm.retrieveWrapper(item);
+ if (wrapper)
+ Shiboken::Object::setParent(0, reinterpret_cast&lt;PyObject*&gt;(wrapper));
+ }
+ </inject-code>
+ </modify-function>
<modify-function signature="items(const QMimeData*)const" remove="all"/>
<!--### Obsolete in 4.3-->
</object-type>
@@ -3228,6 +3240,14 @@
<parent index="this" action="add"/>
</modify-argument>
</modify-function>
+ <modify-function signature="parent()">
+ <modify-argument index="this">
+ <parent index="return" action="add"/>
+ </modify-argument>
+ <modify-argument index="return">
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
<modify-function signature="backgroundColor(int)const" remove="all"/>
<!--### Obsolete in 4.3-->
<modify-function signature="setBackgroundColor(int, QColor)" remove="all"/>
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index fe62e8e..93b9c07 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -21,6 +21,7 @@ PYSIDE_TEST(bug_480.py)
PYSIDE_TEST(bug_500.py)
PYSIDE_TEST(bug_512.py)
PYSIDE_TEST(bug_525.py)
+PYSIDE_TEST(bug_547.py)
PYSIDE_TEST(bug_549.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
diff --git a/tests/QtGui/bug_547.py b/tests/QtGui/bug_547.py
new file mode 100644
index 0000000..5636fb6
--- /dev/null
+++ b/tests/QtGui/bug_547.py
@@ -0,0 +1,39 @@
+""" Unittest for bug #547 """
+""" http://bugs.openbossa.org/show_bug.cgi?id=547 """
+
+from PySide import QtGui
+import sys
+import unittest
+
+class MyMainWindow(unittest.TestCase):
+ def testClearFunction(self):
+ app = QtGui.QApplication(sys.argv)
+ self._tree = QtGui.QTreeWidget()
+ self._tree.setColumnCount(2)
+ self._i1 = None
+ self._i11 = None
+
+ self._updateTree()
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+ self._i11.parent().setExpanded(True)
+ self._i11.setExpanded(True)
+
+ self._updateTree()
+ self.assertEqual(sys.getrefcount(self._i1), 3)
+ self.assertEqual(sys.getrefcount(self._i11), 3)
+
+
+ def _updateTree(self):
+ self._tree.clear()
+ if self._i1 and self._i11:
+ self.assertEqual(sys.getrefcount(self._i1), 2)
+ self.assertEqual(sys.getrefcount(self._i11), 2)
+
+ self._i1 = QtGui.QTreeWidgetItem(self._tree, ['1', ])
+ self._i11 = QtGui.QTreeWidgetItem(self._i1, ['11', ])
+
+if __name__ == '__main__':
+ unittest.main()
+