summaryrefslogtreecommitdiffstats
path: root/tests/QtDeclarative/bug_1113.py
blob: ca697bed57e225f812d444f9f045cc6eb72b943e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
''' unit test for BUG #1113 '''

import sys
from PySide import QtCore, QtGui, QtDeclarative
import helper

class TestModel(QtCore.QAbstractListModel):
    def __init__(self, parent=None):
        super(TestModel, self).__init__(parent)
        self._data = ["one", "two", "three"]
        # this _must_ crash without the fix
        obj = QtCore.QObject()

    def rowCount(self, parent=QtCore.QModelIndex()):
        return len(self._data)

    def data(self, index, role):
        return self._data[index.row()]

if __name__ == "__main__":
    QtDeclarative.qmlRegisterType(TestModel, "Test", 1,0,
                                  "TestModel")

    app = QtGui.QApplication(sys.argv)
    view = QtDeclarative.QDeclarativeView()
    url = QtCore.QUrl.fromLocalFile(helper.adjust_filename("bug_1113.qml",
                                                           __file__))
    view.setSource(url)
    QtCore.QTimer.singleShot(70, app.quit)
    view.show()
    sys.exit(app.exec_())