diff options
-rw-r--r-- | PySide/QtDeclarative/pysideqmlregistertype.cpp | 13 | ||||
-rw-r--r-- | tests/QtDeclarative/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtDeclarative/bug_1113.py | 31 | ||||
-rw-r--r-- | tests/QtDeclarative/bug_1113.qml | 17 |
4 files changed, 58 insertions, 4 deletions
diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp index 4efc4bf..351d917 100644 --- a/PySide/QtDeclarative/pysideqmlregistertype.cpp +++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp @@ -1,7 +1,7 @@ /* * This file is part of the Shiboken Python Bindings Generator project. * - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (C) 2010-2012 Nokia Corporation and/or its subsidiary(-ies). * * Contact: PySide team <contact@pyside.org> * @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "pysideqmlregistertype.h" @@ -58,6 +58,12 @@ static QMutex nextQmlElementMutex; template<int N> struct ElementFactoryBase { + /* Note: PySide::setNextQObjectMemoryAddr() will only be called with a NULL + * argument when the virtual address memory is to be used by any given + * specific object. The generator will take care about adding the proper + * code to handle this. (the PySide::setNextQObjectMemoryAddr() callers are + * met in the Sbk_*_init() functions. + */ static void createInto(void* memory) { QMutexLocker locker(&nextQmlElementMutex); @@ -66,7 +72,6 @@ struct ElementFactoryBase PyObject* obj = PyObject_CallObject(pyTypes[N], 0); if (!obj || PyErr_Occurred()) PyErr_Print(); - PySide::setNextQObjectMemoryAddr(0); } }; @@ -174,7 +179,7 @@ struct DeclarativeListProperty static int propListTpInit(PyObject* self, PyObject* args, PyObject* kwds) { - static const char *kwlist[] = {"type", "append", "at", "clear", "count", 0}; + static const char* kwlist[] = {"type", "append", "at", "clear", "count", 0}; PySideProperty* pySelf = reinterpret_cast<PySideProperty*>(self); DeclarativeListProperty* data = new DeclarativeListProperty; memset(data, 0, sizeof(DeclarativeListProperty)); diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt index 2c842d3..b670f08 100644 --- a/tests/QtDeclarative/CMakeLists.txt +++ b/tests/QtDeclarative/CMakeLists.txt @@ -11,6 +11,7 @@ PYSIDE_TEST(bug_951.py) PYSIDE_TEST(bug_995.py) PYSIDE_TEST(bug_997.py) PYSIDE_TEST(bug_1029.py) +PYSIDE_TEST(bug_1113.py) PYSIDE_TEST(qdeclarativenetwork_test.py) PYSIDE_TEST(qdeclarativeview_test.py) PYSIDE_TEST(connect_python_qml.py) 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_()) diff --git a/tests/QtDeclarative/bug_1113.qml b/tests/QtDeclarative/bug_1113.qml new file mode 100644 index 0000000..0283006 --- /dev/null +++ b/tests/QtDeclarative/bug_1113.qml @@ -0,0 +1,17 @@ +import QtQuick 1.1 +import Test 1.0 + +ListView { + width: 400; height: 240; + + model: TestModel { + } + + delegate: Item { + height: 32 + width: parent.width + Text { + text: model.display + } + } +} |