From 04a2350db6ef1fffa3c81c747b4474e92d1af70d Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 27 Apr 2010 11:55:42 +1000 Subject: Correctly inherit extension properties Correct a typo that breaks extension properties in some cases. --- src/declarative/qml/qdeclarativemetatype.cpp | 2 +- .../gl2paintengineex/qtextureglyphcache_gl_p.h | 2 +- .../qdeclarativeecmascript/testtypes.cpp | 23 ++++++++++++++++++++++ .../tst_qdeclarativeecmascript.cpp | 12 +++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativemetatype.cpp b/src/declarative/qml/qdeclarativemetatype.cpp index d9ea8dc..5fcb7ee 100644 --- a/src/declarative/qml/qdeclarativemetatype.cpp +++ b/src/declarative/qml/qdeclarativemetatype.cpp @@ -247,7 +247,7 @@ static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, QMetaProperty property = mo->property(ii); int otherIndex = ignoreEnd->indexOfProperty(property.name()); - if (otherIndex >= ignoreStart->classInfoOffset() + ignoreStart->classInfoCount()) { + if (otherIndex >= ignoreStart->propertyOffset() + ignoreStart->propertyCount()) { builder.addProperty(QByteArray("__qml_ignore__") + property.name(), QByteArray("void")); // Skip } else { diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h index 04731b1..75c2bb1 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE class QGL2PaintEngineExPrivate; -class QGLTextureGlyphCache : public QObject, public QTextureGlyphCache +class Q_OPENGL_EXPORT QGLTextureGlyphCache : public QObject, public QTextureGlyphCache { Q_OBJECT public: diff --git a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp index 154ff4d..8a4605a 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/testtypes.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ #include "testtypes.h" +#include +#include class BaseExtensionObject : public QObject { @@ -80,6 +82,24 @@ public: DefaultPropertyExtensionObject(QObject *parent) : QObject(parent) {} }; +class QWidgetDeclarativeUI : public QObject +{ + Q_OBJECT + + Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) + +signals: + void widthChanged(); + +public: + QWidgetDeclarativeUI(QObject *other) : QObject(other) { } + +public: + int width() const { return 0; } + void setWidth(int) { } +}; + + void registerTypes() { qmlRegisterType("Qt.test", 1,0, "MyQmlObject"); @@ -91,6 +111,9 @@ void registerTypes() qmlRegisterType("Qt.test", 1,0, "NumberAssignment"); qmlRegisterExtendedType("Qt.test", 1,0, "DefaultPropertyExtendedObject"); qmlRegisterType("Qt.test", 1,0, "OverrideDefaultPropertyObject"); + + qmlRegisterExtendedType("Qt.test",1,0,"QWidget"); + qmlRegisterType("Qt.test",1,0,"QPlainTextEdit"); } #include "testtypes.moc" diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index d0a2f7c..491a736 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -134,6 +134,7 @@ private slots: void numberAssignment(); void bug1(); + void bug2(); void dynamicCreationCrash(); void regExpBug(); void nullObjectBinding(); @@ -1251,6 +1252,17 @@ void tst_qdeclarativeecmascript::bug1() delete object; } +void tst_qdeclarativeecmascript::bug2() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt.test 1.0;\nQPlainTextEdit { width: 100 }", QUrl()); + + QObject *object = component.create(); + QVERIFY(object != 0); + + delete object; +} + // Don't crash in createObject when the component has errors. void tst_qdeclarativeecmascript::dynamicCreationCrash() { -- cgit v0.12