diff options
-rw-r--r-- | PySide/QtDeclarative/pysideqmlregistertype.cpp | 5 | ||||
-rw-r--r-- | tests/QtDeclarative/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtDeclarative/bug_825.py | 55 | ||||
-rw-r--r-- | tests/QtDeclarative/bug_825.qml | 10 |
4 files changed, 66 insertions, 5 deletions
diff --git a/PySide/QtDeclarative/pysideqmlregistertype.cpp b/PySide/QtDeclarative/pysideqmlregistertype.cpp index 0b057586e..f5b878be3 100644 --- a/PySide/QtDeclarative/pysideqmlregistertype.cpp +++ b/PySide/QtDeclarative/pysideqmlregistertype.cpp @@ -104,11 +104,6 @@ int PySide::qmlRegisterType(PyObject* pyObj, const char* uri, int versionMajor, return -1; } - if (pyObj->ob_type != &SbkObjectType_Type) { - PyErr_Format(PyExc_TypeError, "A shiboken-based python type expected, got %s.", pyObj->ob_type->tp_name); - return -1; - } - if (!PySequence_Contains(((PyTypeObject*)pyObj)->tp_mro, (PyObject*)declarativeItemType)) { PyErr_Format(PyExc_TypeError, "A type inherited from %s expected, got %s.", declarativeItemType->tp_name, ((PyTypeObject*)pyObj)->tp_name); return -1; diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt index 7cad2d7ff..abde6fb80 100644 --- a/tests/QtDeclarative/CMakeLists.txt +++ b/tests/QtDeclarative/CMakeLists.txt @@ -3,6 +3,7 @@ PYSIDE_TEST(bug_456.py) PYSIDE_TEST(bug_557.py) PYSIDE_TEST(bug_726.py) PYSIDE_TEST(bug_814.py) +PYSIDE_TEST(bug_825.py) PYSIDE_TEST(qdeclarativenetwork_test.py) PYSIDE_TEST(qdeclarativeview_test.py) PYSIDE_TEST(connect_python_qml.py) diff --git a/tests/QtDeclarative/bug_825.py b/tests/QtDeclarative/bug_825.py new file mode 100644 index 000000000..d3c5519aa --- /dev/null +++ b/tests/QtDeclarative/bug_825.py @@ -0,0 +1,55 @@ +from PySide.QtCore import * +from PySide.QtGui import * +from PySide.QtDeclarative import * + +from helper import adjust_filename +import unittest + +paintCalled = False + +class MetaA(type): + pass + +class A(object): + __metaclass__ = MetaA + +MetaB = type(QDeclarativeItem) +B = QDeclarativeItem + +class MetaC(MetaA, MetaB): + pass + +class C(A, B): + __metaclass__ = MetaC + +class Bug825 (C): + + def __init__(self, parent = None): + QDeclarativeItem.__init__(self, parent) + # need to disable this flag to draw inside a QDeclarativeItem + self.setFlag(QGraphicsItem.ItemHasNoContents, False) + + def paint(self, painter, options, widget): + global paintCalled + pen = QPen(Qt.black, 2) + painter.setPen(pen); + painter.drawPie(self.boundingRect(), 0, 128); + paintCalled = True + +class TestBug825 (unittest.TestCase): + def testIt(self): + global paintCalled + app = QApplication([]) + qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825') + self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A') + + view = QDeclarativeView() + view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__))) + view.show() + QTimer.singleShot(250, view.close) + app.exec_() + self.assertTrue(paintCalled) + + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtDeclarative/bug_825.qml b/tests/QtDeclarative/bug_825.qml new file mode 100644 index 000000000..dc1c450db --- /dev/null +++ b/tests/QtDeclarative/bug_825.qml @@ -0,0 +1,10 @@ +import Qt 4.7 +import bugs 1.0 + +Item { + width: 300; height: 200 + + Bug825 { + + } +} |