diff options
author | Paulo Alcantara <pcacjr@gmail.com> | 2012-01-18 14:23:29 -0300 |
---|---|---|
committer | Paulo Alcantara <pcacjr@gmail.com> | 2012-01-18 18:36:46 -0300 |
commit | 3aba7ebbf7ae05804d96dc1db9edad3926c89ee5 (patch) | |
tree | b2b8eb6864d8433ef6b060c24e8b077db8ce23ae /tests/QtDeclarative/bug_1113.py | |
parent | a50e42645e01662db3875e5872e84ca80ed84464 (diff) | |
download | pyside-3aba7ebbf7ae05804d96dc1db9edad3926c89ee5.tar.gz pyside-3aba7ebbf7ae05804d96dc1db9edad3926c89ee5.tar.xz pyside-3aba7ebbf7ae05804d96dc1db9edad3926c89ee5.zip |
Fix BUG #1113 - "Instantiating QObject in user-defined QML element's
constructor crashes if instantiated from QML"
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>
Diffstat (limited to 'tests/QtDeclarative/bug_1113.py')
-rw-r--r-- | tests/QtDeclarative/bug_1113.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/QtDeclarative/bug_1113.py b/tests/QtDeclarative/bug_1113.py new file mode 100644 index 0000000..ca697be --- /dev/null +++ b/tests/QtDeclarative/bug_1113.py @@ -0,0 +1,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_()) |