summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@gmail.com>2012-01-11 15:16:48 -0300
committerPaulo Alcantara <pcacjr@gmail.com>2012-01-11 17:44:10 -0300
commita50e42645e01662db3875e5872e84ca80ed84464 (patch)
treead1a866f9a24f69c7f6f8bfb34f9c6434ad59c36
parent2ae8e750f77fe68bef2041019f3493487f8c3afc (diff)
downloadpyside-a50e42645e01662db3875e5872e84ca80ed84464.tar.gz
pyside-a50e42645e01662db3875e5872e84ca80ed84464.tar.xz
pyside-a50e42645e01662db3875e5872e84ca80ed84464.zip
Fix BUG #1041 - "QAbstractItemModel has wrong ownership policy for
selectionModel()" See http://bugs.pyside.org/show_bug.cgi?id=1041. Signed-off-by: Paulo Alcantara <pcacjr@gmail.com> Reviewed-by: Marcelo Lira <marcelo.lira@openbossa.org> Reviewed-by: Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--PySide/QtGui/typesystem_gui_common.xml7
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_1041.py35
3 files changed, 43 insertions, 0 deletions
diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml
index 552636a..14a4ef7 100644
--- a/PySide/QtGui/typesystem_gui_common.xml
+++ b/PySide/QtGui/typesystem_gui_common.xml
@@ -1890,6 +1890,13 @@
<define-ownership class="target" owner="default"/>
</modify-argument>
</modify-function>
+ <modify-function signature="selectionModel() const">
+ <modify-argument index="return">
+ <!-- Defining ownership as "default" avoids the object to be
+ automatically set as parent of the returned pointer. -->
+ <define-ownership class="target" owner="default"/>
+ </modify-argument>
+ </modify-function>
<modify-function signature="setIndexWidget(const QModelIndex &amp;, QWidget *)">
<modify-argument index="2">
<parent index="this" action="add"/>
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 9bac913..5998ca5 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -79,6 +79,7 @@ PYSIDE_TEST(bug_991.py)
PYSIDE_TEST(bug_998.py)
PYSIDE_TEST(bug_1002.py)
PYSIDE_TEST(bug_1006.py)
+PYSIDE_TEST(bug_1041.py)
PYSIDE_TEST(bug_1048.py)
PYSIDE_TEST(bug_1077.py)
PYSIDE_TEST(customproxywidget_test.py)
diff --git a/tests/QtGui/bug_1041.py b/tests/QtGui/bug_1041.py
new file mode 100644
index 0000000..735bf73
--- /dev/null
+++ b/tests/QtGui/bug_1041.py
@@ -0,0 +1,35 @@
+''' unit test for BUG #1041 '''
+
+import sys
+from PySide.QtGui import *
+from PySide.QtCore import *
+
+class BugWindow(QMainWindow):
+ def __init__(self):
+ super(BugWindow, self).__init__()
+ self.setCentralWidget(QTableView())
+ self.timer = QTimer(self)
+ self.timer.timeout.connect(self.doTest)
+ self.timer.start(20)
+ self.count = 0
+
+ @Slot()
+ def doTest(self):
+ self.m = QStandardItemModel(1, 1, None)
+
+ try:
+ table = self.centralWidget()
+ table.setModel(self.m)
+ table.selectionModel()
+ except AttributeError:
+ sys.exit(-1)
+
+ if self.count >= 50:
+ QApplication.instance().quit()
+
+ self.count += 1
+
+if __name__ == "__main__":
+ app = QApplication(sys.argv)
+ window = BugWindow()
+ sys.exit(app.exec_())