From a9f932ab1ee658ded7e5246248fded0655e9218a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 4 Aug 2009 17:23:01 +1000 Subject: Fix to use "." not "/" in QML_DEFINE_TYPE URIs Fix to allow multiple version specifying defines. --- src/declarative/qml/qml.h | 10 +++++----- src/declarative/qml/qmlcustomparser_p.h | 2 +- src/declarative/qml/qmlmetatype.cpp | 14 +++++++++----- src/declarative/qml/qmlprivate.h | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index e7fbff3..bced8f2 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -74,19 +74,19 @@ QT_MODULE(Declarative) QT_BEGIN_NAMESPACE #define QML_DEFINE_INTERFACE(INTERFACE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterInterface(#INTERFACE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterInterface(#INTERFACE)); #define QML_DEFINE_EXTENDED_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); #define QML_DEFINE_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, NAME, TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MIN_TO, #NAME, #TYPE)); #define QML_DEFINE_EXTENDED_NOCREATE_TYPE(TYPE, EXTENSION) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterExtendedType(#TYPE)); #define QML_DEFINE_NOCREATE_TYPE(TYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#TYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterType(#TYPE)); class QmlContext; class QmlEngine; diff --git a/src/declarative/qml/qmlcustomparser_p.h b/src/declarative/qml/qmlcustomparser_p.h index 3d55d3e..74bd15c 100644 --- a/src/declarative/qml/qmlcustomparser_p.h +++ b/src/declarative/qml/qmlcustomparser_p.h @@ -113,7 +113,7 @@ public: virtual void setCustomData(QObject *, const QByteArray &); }; #define QML_DEFINE_CUSTOM_TYPE(URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, NAME, TYPE, CUSTOMTYPE) \ - template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE)); + template<> QmlPrivate::InstanceType QmlPrivate::Define::instance(qmlRegisterCustomType(#URI, VERSION_MAJ, VERSION_MIN_FROM, VERSION_MAJ_TO, #NAME, #TYPE, new CUSTOMTYPE)); QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 5fe3eff..29fe026 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -448,16 +448,20 @@ int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Fun int pStatus, int object, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser) { Q_UNUSED(object); - QByteArray name = cname; - + QByteArray name; if (uri) { + // Convert to path + name = uri; + name.replace('.','/'); if (version) { - name = QByteArray(uri) + '/' + version + '/' + name; - } else { - name = QByteArray(uri) + '/' + name; + name += '/'; + name += version; } + name += '/'; + name += cname; } else { // No URI? No version! + name = cname; Q_ASSERT(!version); } diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index 3d5fa61..e821759 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -240,7 +240,7 @@ namespace QmlPrivate InstanceType(int); }; - template + template struct Define { static InstanceType instance; }; -- cgit v0.12 From 380f397b9055b5c1aa4c46989656b59f6f7f9c88 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 4 Aug 2009 17:23:49 +1000 Subject: Fix imports. Add import tests. --- tests/auto/declarative/qmlparser/MyComponent.qml | 2 +- .../declarative/qmlparser/MyContainerComponent.qml | 2 +- .../declarative/qmlparser/assignBasicTypes.txt | 1 + .../qmlparser/assignLiteralSignalProperty.txt | 1 + .../declarative/qmlparser/assignObjectToSignal.txt | 1 + .../qmlparser/assignObjectToVariant.txt | 2 + .../declarative/qmlparser/assignQmlComponent.txt | 1 + tests/auto/declarative/qmlparser/assignSignal.txt | 1 + .../declarative/qmlparser/assignTypeExtremes.txt | 1 + .../declarative/qmlparser/attachedProperties.txt | 2 + .../qmlparser/autoComponentCreation.txt | 1 + .../declarative/qmlparser/customParserTypes.txt | 1 + .../declarative/qmlparser/customVariantTypes.txt | 1 + .../declarative/qmlparser/duplicateIDs.errors.txt | 2 +- tests/auto/declarative/qmlparser/duplicateIDs.txt | 1 + .../auto/declarative/qmlparser/dynamicObject.1.txt | 2 + .../declarative/qmlparser/dynamicProperties.txt | 2 + .../qmlparser/dynamicSignalsAndSlots.txt | 1 + tests/auto/declarative/qmlparser/empty.errors.txt | 3 +- .../qmlparser/failingComponent.errors.txt | 2 +- .../declarative/qmlparser/failingComponent.txt | 1 + .../qmlparser/fakeDotProperty.errors.txt | 2 +- .../auto/declarative/qmlparser/fakeDotProperty.txt | 1 + .../declarative/qmlparser/finalOverride.errors.txt | 2 +- tests/auto/declarative/qmlparser/finalOverride.txt | 1 + tests/auto/declarative/qmlparser/idProperty.txt | 1 + .../declarative/qmlparser/inlineQmlComponents.txt | 2 + .../declarative/qmlparser/interfaceProperty.txt | 4 +- .../auto/declarative/qmlparser/interfaceQList.txt | 1 + .../declarative/qmlparser/interfaceQmlList.txt | 1 + .../declarative/qmlparser/invalidID.2.errors.txt | 2 +- tests/auto/declarative/qmlparser/invalidID.2.txt | 1 + .../declarative/qmlparser/invalidID.3.errors.txt | 2 +- tests/auto/declarative/qmlparser/invalidID.3.txt | 1 + .../declarative/qmlparser/invalidID.4.errors.txt | 2 +- tests/auto/declarative/qmlparser/invalidID.4.txt | 1 + .../declarative/qmlparser/invalidID.errors.txt | 2 +- tests/auto/declarative/qmlparser/invalidID.txt | 1 + .../qmlparser/listAssignment.1.errors.txt | 2 +- .../declarative/qmlparser/listAssignment.1.txt | 1 + .../qmlparser/listAssignment.2.errors.txt | 2 +- .../declarative/qmlparser/listAssignment.2.txt | 1 + .../qmlparser/listAssignment.3.errors.txt | 2 +- .../declarative/qmlparser/listAssignment.3.txt | 1 + .../declarative/qmlparser/missingObject.errors.txt | 2 +- .../declarative/qmlparser/missingSignal.errors.txt | 2 +- tests/auto/declarative/qmlparser/missingSignal.txt | 2 + .../qmlparser/nonexistantProperty.1.errors.txt | 2 +- .../qmlparser/nonexistantProperty.1.txt | 1 + .../qmlparser/nonexistantProperty.2.errors.txt | 2 +- .../qmlparser/nonexistantProperty.2.txt | 1 + .../qmlparser/nonexistantProperty.3.errors.txt | 2 +- .../qmlparser/nonexistantProperty.3.txt | 1 + .../qmlparser/nonexistantProperty.4.errors.txt | 2 +- .../qmlparser/nonexistantProperty.4.txt | 1 + .../qmlparser/nonexistantProperty.5.errors.txt | 2 +- .../qmlparser/nonexistantProperty.5.txt | 1 + .../qmlparser/nonexistantProperty.6.errors.txt | 2 +- .../qmlparser/nonexistantProperty.6.txt | 1 + .../qmlparser/nullDotProperty.errors.txt | 2 +- .../auto/declarative/qmlparser/nullDotProperty.txt | 1 + .../declarative/qmlparser/propertyValueSource.txt | 1 + .../declarative/qmlparser/readOnly.1.errors.txt | 2 +- tests/auto/declarative/qmlparser/readOnly.1.txt | 1 + .../declarative/qmlparser/readOnly.2.errors.txt | 2 +- tests/auto/declarative/qmlparser/readOnly.2.txt | 1 + .../declarative/qmlparser/rootAsQmlComponent.txt | 1 + .../auto/declarative/qmlparser/simpleBindings.txt | 1 + .../auto/declarative/qmlparser/simpleContainer.txt | 1 + tests/auto/declarative/qmlparser/simpleObject.txt | 1 + tests/auto/declarative/qmlparser/testtypes.cpp | 10 +-- tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 99 ++++++++++++++++++++-- .../declarative/qmlparser/unregisteredObject.txt | 1 + .../qmlparser/unsupportedProperty.errors.txt | 2 +- .../declarative/qmlparser/unsupportedProperty.txt | 1 + tests/auto/declarative/qmlparser/valueTypes.txt | 1 + .../declarative/qmlparser/wrongType.1.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.1.txt | 1 + .../declarative/qmlparser/wrongType.10.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.10.txt | 1 + .../declarative/qmlparser/wrongType.11.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.11.txt | 1 + .../declarative/qmlparser/wrongType.12.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.12.txt | 1 + .../declarative/qmlparser/wrongType.13.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.13.txt | 1 + .../declarative/qmlparser/wrongType.14.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.14.txt | 1 + .../declarative/qmlparser/wrongType.2.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.2.txt | 1 + .../declarative/qmlparser/wrongType.3.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.3.txt | 1 + .../declarative/qmlparser/wrongType.4.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.4.txt | 1 + .../declarative/qmlparser/wrongType.5.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.5.txt | 1 + .../declarative/qmlparser/wrongType.6.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.6.txt | 1 + .../declarative/qmlparser/wrongType.7.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.7.txt | 1 + .../declarative/qmlparser/wrongType.8.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.8.txt | 1 + .../declarative/qmlparser/wrongType.9.errors.txt | 2 +- tests/auto/declarative/qmlparser/wrongType.9.txt | 1 + 104 files changed, 209 insertions(+), 52 deletions(-) diff --git a/tests/auto/declarative/qmlparser/MyComponent.qml b/tests/auto/declarative/qmlparser/MyComponent.qml index 5caa547..1a23277 100644 --- a/tests/auto/declarative/qmlparser/MyComponent.qml +++ b/tests/auto/declarative/qmlparser/MyComponent.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Test 1.0 MyQmlObject { property real x; diff --git a/tests/auto/declarative/qmlparser/MyContainerComponent.qml b/tests/auto/declarative/qmlparser/MyContainerComponent.qml index cf17dcc..61f54c5 100644 --- a/tests/auto/declarative/qmlparser/MyContainerComponent.qml +++ b/tests/auto/declarative/qmlparser/MyContainerComponent.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Test 1.0 MyContainer { property int x diff --git a/tests/auto/declarative/qmlparser/assignBasicTypes.txt b/tests/auto/declarative/qmlparser/assignBasicTypes.txt index 71e400d..cef9f8d 100644 --- a/tests/auto/declarative/qmlparser/assignBasicTypes.txt +++ b/tests/auto/declarative/qmlparser/assignBasicTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { flagProperty: "FlagVal1 | FlagVal3" enumProperty: "EnumVal2" diff --git a/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt b/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt index f3a7ac7..399fcea 100644 --- a/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt +++ b/tests/auto/declarative/qmlparser/assignLiteralSignalProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onLiteralSignal: 10 } diff --git a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt index 0d6bc4e..789cc66 100644 --- a/tests/auto/declarative/qmlparser/assignObjectToSignal.txt +++ b/tests/auto/declarative/qmlparser/assignObjectToSignal.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onBasicSignal: MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/assignObjectToVariant.txt b/tests/auto/declarative/qmlparser/assignObjectToVariant.txt index 180221d..28c68c4 100644 --- a/tests/auto/declarative/qmlparser/assignObjectToVariant.txt +++ b/tests/auto/declarative/qmlparser/assignObjectToVariant.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { property var a; a: MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/assignQmlComponent.txt b/tests/auto/declarative/qmlparser/assignQmlComponent.txt index 6b6d77f..20bdc55 100644 --- a/tests/auto/declarative/qmlparser/assignQmlComponent.txt +++ b/tests/auto/declarative/qmlparser/assignQmlComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyComponent { x: 10; y: 11; } } diff --git a/tests/auto/declarative/qmlparser/assignSignal.txt b/tests/auto/declarative/qmlparser/assignSignal.txt index 6c0fd54..153b403 100644 --- a/tests/auto/declarative/qmlparser/assignSignal.txt +++ b/tests/auto/declarative/qmlparser/assignSignal.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { onBasicSignal: basicSlot() } diff --git a/tests/auto/declarative/qmlparser/assignTypeExtremes.txt b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt index dbd281a..60ede52 100644 --- a/tests/auto/declarative/qmlparser/assignTypeExtremes.txt +++ b/tests/auto/declarative/qmlparser/assignTypeExtremes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { uintProperty: 4000000000 intProperty: -2000000000 diff --git a/tests/auto/declarative/qmlparser/attachedProperties.txt b/tests/auto/declarative/qmlparser/attachedProperties.txt index bfe5733..8343754 100644 --- a/tests/auto/declarative/qmlparser/attachedProperties.txt +++ b/tests/auto/declarative/qmlparser/attachedProperties.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { MyQmlObject.value: 10 } diff --git a/tests/auto/declarative/qmlparser/autoComponentCreation.txt b/tests/auto/declarative/qmlparser/autoComponentCreation.txt index e0dbbae..5d00144 100644 --- a/tests/auto/declarative/qmlparser/autoComponentCreation.txt +++ b/tests/auto/declarative/qmlparser/autoComponentCreation.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { componentProperty : MyTypeObject { realProperty: 9 } } diff --git a/tests/auto/declarative/qmlparser/customParserTypes.txt b/tests/auto/declarative/qmlparser/customParserTypes.txt index 52848fa..cf2f272 100644 --- a/tests/auto/declarative/qmlparser/customParserTypes.txt +++ b/tests/auto/declarative/qmlparser/customParserTypes.txt @@ -1,3 +1,4 @@ +import Qt 4.6 ListModel { ListElement { a: 10 } ListElement { a: 12 } diff --git a/tests/auto/declarative/qmlparser/customVariantTypes.txt b/tests/auto/declarative/qmlparser/customVariantTypes.txt index dc5031e..0263ed2 100644 --- a/tests/auto/declarative/qmlparser/customVariantTypes.txt +++ b/tests/auto/declarative/qmlparser/customVariantTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { customType: "10" } diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt index 99f4c7c..66241cf 100644 --- a/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt +++ b/tests/auto/declarative/qmlparser/duplicateIDs.errors.txt @@ -1 +1 @@ -3:19:id is not unique +4:19:id is not unique diff --git a/tests/auto/declarative/qmlparser/duplicateIDs.txt b/tests/auto/declarative/qmlparser/duplicateIDs.txt index e76ee21..9605b5b 100644 --- a/tests/auto/declarative/qmlparser/duplicateIDs.txt +++ b/tests/auto/declarative/qmlparser/duplicateIDs.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyQmlObject { id: MyID } MyQmlObject { id: MyID } diff --git a/tests/auto/declarative/qmlparser/dynamicObject.1.txt b/tests/auto/declarative/qmlparser/dynamicObject.1.txt index ac892c3..4be0c8d 100644 --- a/tests/auto/declarative/qmlparser/dynamicObject.1.txt +++ b/tests/auto/declarative/qmlparser/dynamicObject.1.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 SetProperties { propa: a + 10 propb: Math.min(a, 10) diff --git a/tests/auto/declarative/qmlparser/dynamicProperties.txt b/tests/auto/declarative/qmlparser/dynamicProperties.txt index 14c85a7..f93e446 100644 --- a/tests/auto/declarative/qmlparser/dynamicProperties.txt +++ b/tests/auto/declarative/qmlparser/dynamicProperties.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { default property int intProperty : 10 property bool boolProperty: false diff --git a/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt index 7cf65ee..b0ca970 100644 --- a/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt +++ b/tests/auto/declarative/qmlparser/dynamicSignalsAndSlots.txt @@ -1,3 +1,4 @@ +import Qt 4.6 Object { signal signal1 function slot1() {} diff --git a/tests/auto/declarative/qmlparser/empty.errors.txt b/tests/auto/declarative/qmlparser/empty.errors.txt index e0ed268..d416e76 100644 --- a/tests/auto/declarative/qmlparser/empty.errors.txt +++ b/tests/auto/declarative/qmlparser/empty.errors.txt @@ -1 +1,2 @@ -0:0:Expected token `identifier' +0:0:Expected token `numeric literal' +0:0:Expected a qualified name id diff --git a/tests/auto/declarative/qmlparser/failingComponent.errors.txt b/tests/auto/declarative/qmlparser/failingComponent.errors.txt index a18f2e7..388fa76 100644 --- a/tests/auto/declarative/qmlparser/failingComponent.errors.txt +++ b/tests/auto/declarative/qmlparser/failingComponent.errors.txt @@ -1,2 +1,2 @@ -1:-1:Unable to create type FailingComponent -2:5:Cannot assign to non-existant property "a" +4:5:Cannot assign to non-existant property "a" diff --git a/tests/auto/declarative/qmlparser/failingComponent.txt b/tests/auto/declarative/qmlparser/failingComponent.txt index 8c43f84..bc21243 100644 --- a/tests/auto/declarative/qmlparser/failingComponent.txt +++ b/tests/auto/declarative/qmlparser/failingComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { FailingComponent {} } diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt index 989d0e6..e56ad3a 100644 --- a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt @@ -1 +1 @@ -2:5:Invalid property access +3:5:Invalid property access diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.txt index 28eb9dc..d971eee 100644 --- a/tests/auto/declarative/qmlparser/fakeDotProperty.txt +++ b/tests/auto/declarative/qmlparser/fakeDotProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value.something: "hello" } diff --git a/tests/auto/declarative/qmlparser/finalOverride.errors.txt b/tests/auto/declarative/qmlparser/finalOverride.errors.txt index fc7070c..49e06cb 100644 --- a/tests/auto/declarative/qmlparser/finalOverride.errors.txt +++ b/tests/auto/declarative/qmlparser/finalOverride.errors.txt @@ -1 +1 @@ -2:5:Cannot override FINAL property +3:5:Cannot override FINAL property diff --git a/tests/auto/declarative/qmlparser/finalOverride.txt b/tests/auto/declarative/qmlparser/finalOverride.txt index 54ea6fb..a84393a 100644 --- a/tests/auto/declarative/qmlparser/finalOverride.txt +++ b/tests/auto/declarative/qmlparser/finalOverride.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { property int value: 10 } diff --git a/tests/auto/declarative/qmlparser/idProperty.txt b/tests/auto/declarative/qmlparser/idProperty.txt index c3c2e50..a413c0b 100644 --- a/tests/auto/declarative/qmlparser/idProperty.txt +++ b/tests/auto/declarative/qmlparser/idProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { property var object : MyObjectId diff --git a/tests/auto/declarative/qmlparser/inlineQmlComponents.txt b/tests/auto/declarative/qmlparser/inlineQmlComponents.txt index e713a88..79ceda6 100644 --- a/tests/auto/declarative/qmlparser/inlineQmlComponents.txt +++ b/tests/auto/declarative/qmlparser/inlineQmlComponents.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 MyContainer { Component { id: MyComponent diff --git a/tests/auto/declarative/qmlparser/interfaceProperty.txt b/tests/auto/declarative/qmlparser/interfaceProperty.txt index cbad7f1..c9a20fb 100644 --- a/tests/auto/declarative/qmlparser/interfaceProperty.txt +++ b/tests/auto/declarative/qmlparser/interfaceProperty.txt @@ -1,3 +1,5 @@ -MyQmlObject { +import Test 1.0 +import Qt 4.6 +Object { interface: MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/interfaceQList.txt b/tests/auto/declarative/qmlparser/interfaceQList.txt index 6c6ab4b..c87dfae 100644 --- a/tests/auto/declarative/qmlparser/interfaceQList.txt +++ b/tests/auto/declarative/qmlparser/interfaceQList.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qlistInterfaces: [ MyQmlObject {}, diff --git a/tests/auto/declarative/qmlparser/interfaceQmlList.txt b/tests/auto/declarative/qmlparser/interfaceQmlList.txt index f41c105..8392bea 100644 --- a/tests/auto/declarative/qmlparser/interfaceQmlList.txt +++ b/tests/auto/declarative/qmlparser/interfaceQmlList.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qmllistInterfaces: [ MyQmlObject {}, diff --git a/tests/auto/declarative/qmlparser/invalidID.2.errors.txt b/tests/auto/declarative/qmlparser/invalidID.2.errors.txt index 9c54aab..56e3eeb 100644 --- a/tests/auto/declarative/qmlparser/invalidID.2.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.2.errors.txt @@ -1,2 +1,2 @@ -2:5:"" is not a valid object id +3:5:"" is not a valid object id diff --git a/tests/auto/declarative/qmlparser/invalidID.2.txt b/tests/auto/declarative/qmlparser/invalidID.2.txt index a7af29e..4fb3b29 100644 --- a/tests/auto/declarative/qmlparser/invalidID.2.txt +++ b/tests/auto/declarative/qmlparser/invalidID.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: "" } diff --git a/tests/auto/declarative/qmlparser/invalidID.3.errors.txt b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt index 36cd489..bb811cf 100644 --- a/tests/auto/declarative/qmlparser/invalidID.3.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.3.errors.txt @@ -1 +1 @@ -2:5:Invalid use of id property +3:5:Invalid use of id property diff --git a/tests/auto/declarative/qmlparser/invalidID.3.txt b/tests/auto/declarative/qmlparser/invalidID.3.txt index c686914..6684172 100644 --- a/tests/auto/declarative/qmlparser/invalidID.3.txt +++ b/tests/auto/declarative/qmlparser/invalidID.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id.other: 10 } diff --git a/tests/auto/declarative/qmlparser/invalidID.4.errors.txt b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt index bb811cf..cfe8756 100644 --- a/tests/auto/declarative/qmlparser/invalidID.4.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.4.errors.txt @@ -1 +1 @@ -3:5:Invalid use of id property +4:5:Invalid use of id property diff --git a/tests/auto/declarative/qmlparser/invalidID.4.txt b/tests/auto/declarative/qmlparser/invalidID.4.txt index 734ccc4..1f15fce 100644 --- a/tests/auto/declarative/qmlparser/invalidID.4.txt +++ b/tests/auto/declarative/qmlparser/invalidID.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: Hello id: World diff --git a/tests/auto/declarative/qmlparser/invalidID.errors.txt b/tests/auto/declarative/qmlparser/invalidID.errors.txt index 7cefb7e..1ca678c 100644 --- a/tests/auto/declarative/qmlparser/invalidID.errors.txt +++ b/tests/auto/declarative/qmlparser/invalidID.errors.txt @@ -1 +1 @@ -2:5:"1" is not a valid object id +3:5:"1" is not a valid object id diff --git a/tests/auto/declarative/qmlparser/invalidID.txt b/tests/auto/declarative/qmlparser/invalidID.txt index f91e8c4..04db3eb 100644 --- a/tests/auto/declarative/qmlparser/invalidID.txt +++ b/tests/auto/declarative/qmlparser/invalidID.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { id: 1 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt index 8bcd71e..d68d487 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.1.errors.txt @@ -1 +1 @@ -2:24:Cannot assign primitives to lists +3:24:Cannot assign primitives to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.1.txt b/tests/auto/declarative/qmlparser/listAssignment.1.txt index e2376f2..4240425 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.1.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { qmllistInterfaces: 1 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt index 312ba8a..8b40aa3 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.2.errors.txt @@ -1,2 +1,2 @@ -2:15:Cannot assign primitives to lists +3:15:Cannot assign primitives to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.2.txt b/tests/auto/declarative/qmlparser/listAssignment.2.txt index 375e4b4..e3baadb 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.2.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { children: 2 } diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt index c52debf..8c7b7e9 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.3.errors.txt @@ -1 +1 @@ -3:15:Can only assign one binding to lists +4:15:Can only assign one binding to lists diff --git a/tests/auto/declarative/qmlparser/listAssignment.3.txt b/tests/auto/declarative/qmlparser/listAssignment.3.txt index b776bee..00c4c6b 100644 --- a/tests/auto/declarative/qmlparser/listAssignment.3.txt +++ b/tests/auto/declarative/qmlparser/listAssignment.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { children: childBinding.expression children: childBinding2.expression diff --git a/tests/auto/declarative/qmlparser/missingObject.errors.txt b/tests/auto/declarative/qmlparser/missingObject.errors.txt index 8438b9e..b31b562 100644 --- a/tests/auto/declarative/qmlparser/missingObject.errors.txt +++ b/tests/auto/declarative/qmlparser/missingObject.errors.txt @@ -1 +1 @@ -1:10:Syntax error +1:10:Expected token `{' diff --git a/tests/auto/declarative/qmlparser/missingSignal.errors.txt b/tests/auto/declarative/qmlparser/missingSignal.errors.txt index bcee331..e243ae5 100644 --- a/tests/auto/declarative/qmlparser/missingSignal.errors.txt +++ b/tests/auto/declarative/qmlparser/missingSignal.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "onClicked" +4:5:Cannot assign to non-existant property "onClicked" diff --git a/tests/auto/declarative/qmlparser/missingSignal.txt b/tests/auto/declarative/qmlparser/missingSignal.txt index 07d1bfa..fd489ca 100644 --- a/tests/auto/declarative/qmlparser/missingSignal.txt +++ b/tests/auto/declarative/qmlparser/missingSignal.txt @@ -1,3 +1,5 @@ +import Test 1.0 +import Qt 4.6 Object { onClicked: print("Hello world!") } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt index 6f85946..cfc6fc8 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.errors.txt @@ -1 +1 @@ -1:15:Cannot assign to non-existant property "something" +2:15:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt index 5023b38..df7406c 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.1.txt @@ -1 +1,2 @@ +import Test 1.0 MyQmlObject { something: 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt index 3b6cfa6..06ccd37 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt index 61f3625..5b08608 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: 1 + 1 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt index 8d6dfb4..8b13585 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant property "something" +3:5:Cannot assign to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt index 5ee1d3a..6579191 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { something: ; } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt index 4234fca4..c07f2b9 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.errors.txt @@ -1 +1 @@ -2:5:Unexpected token `numeric literal' +3:5:Expected a qualified name id diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt index 1dc6985..37af057 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.5.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { 24 } diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt index fac833e..c02d7bd 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.errors.txt @@ -1 +1 @@ -2:5:Cannot assign to non-existant default property +3:5:Cannot assign to non-existant default property diff --git a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt index 4940833..5cd55d0 100644 --- a/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt +++ b/tests/auto/declarative/qmlparser/nonexistantProperty.6.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { MyQmlObject {} } diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt index 8482634..07a4094 100644 --- a/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/nullDotProperty.errors.txt @@ -1 +1 @@ -2:-1:Cannot set properties on obj as it is null +3:-1:Cannot set properties on obj as it is null diff --git a/tests/auto/declarative/qmlparser/nullDotProperty.txt b/tests/auto/declarative/qmlparser/nullDotProperty.txt index 5c60c5b..4e36779 100644 --- a/tests/auto/declarative/qmlparser/nullDotProperty.txt +++ b/tests/auto/declarative/qmlparser/nullDotProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyDotPropertyObject { obj.value: 1 } diff --git a/tests/auto/declarative/qmlparser/propertyValueSource.txt b/tests/auto/declarative/qmlparser/propertyValueSource.txt index 780f527..ad71fcf 100644 --- a/tests/auto/declarative/qmlparser/propertyValueSource.txt +++ b/tests/auto/declarative/qmlparser/propertyValueSource.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { intProperty : MyPropertyValueSource {} } diff --git a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt index 8608370..97219af 100644 --- a/tests/auto/declarative/qmlparser/readOnly.1.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.1.errors.txt @@ -1 +1 @@ -2:21:Invalid property assignment: read-only property +3:21:Invalid property assignment: read-only property diff --git a/tests/auto/declarative/qmlparser/readOnly.1.txt b/tests/auto/declarative/qmlparser/readOnly.1.txt index c47fdf3..60757bd 100644 --- a/tests/auto/declarative/qmlparser/readOnly.1.txt +++ b/tests/auto/declarative/qmlparser/readOnly.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { readOnlyString: "Hello World" } diff --git a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt index 633d56f..471505c 100644 --- a/tests/auto/declarative/qmlparser/readOnly.2.errors.txt +++ b/tests/auto/declarative/qmlparser/readOnly.2.errors.txt @@ -1 +1 @@ -2:5:Invalid property assignment: read-only property +3:5:Invalid property assignment: read-only property diff --git a/tests/auto/declarative/qmlparser/readOnly.2.txt b/tests/auto/declarative/qmlparser/readOnly.2.txt index 2b6f733..8f1633c 100644 --- a/tests/auto/declarative/qmlparser/readOnly.2.txt +++ b/tests/auto/declarative/qmlparser/readOnly.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { readOnlyString: "Hello" + "World" } diff --git a/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt b/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt index 8cb57ff..8d72cd3 100644 --- a/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt +++ b/tests/auto/declarative/qmlparser/rootAsQmlComponent.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainerComponent { x: 11 MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/simpleBindings.txt b/tests/auto/declarative/qmlparser/simpleBindings.txt index 78f2503..74867b3 100644 --- a/tests/auto/declarative/qmlparser/simpleBindings.txt +++ b/tests/auto/declarative/qmlparser/simpleBindings.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { id: Me property int v1: 10 diff --git a/tests/auto/declarative/qmlparser/simpleContainer.txt b/tests/auto/declarative/qmlparser/simpleContainer.txt index 8b30ed9..c3a795f 100644 --- a/tests/auto/declarative/qmlparser/simpleContainer.txt +++ b/tests/auto/declarative/qmlparser/simpleContainer.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyContainer { MyQmlObject {} MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/simpleObject.txt b/tests/auto/declarative/qmlparser/simpleObject.txt index 05ed87a..30c7823 100644 --- a/tests/auto/declarative/qmlparser/simpleObject.txt +++ b/tests/auto/declarative/qmlparser/simpleObject.txt @@ -1 +1,2 @@ +import Test 1.0 MyQmlObject {} diff --git a/tests/auto/declarative/qmlparser/testtypes.cpp b/tests/auto/declarative/qmlparser/testtypes.cpp index 69df5c3..19776a9 100644 --- a/tests/auto/declarative/qmlparser/testtypes.cpp +++ b/tests/auto/declarative/qmlparser/testtypes.cpp @@ -1,9 +1,9 @@ #include "testtypes.h" QML_DEFINE_INTERFACE(MyInterface); -QML_DEFINE_TYPE(MyQmlObject,MyQmlObject); -QML_DEFINE_TYPE(MyTypeObject,MyTypeObject); -QML_DEFINE_TYPE(MyContainer,MyContainer); -QML_DEFINE_TYPE(MyPropertyValueSource,MyPropertyValueSource); -QML_DEFINE_TYPE(MyDotPropertyObject,MyDotPropertyObject); +QML_DEFINE_TYPE(Test,1,0,0,MyQmlObject,MyQmlObject); +QML_DEFINE_TYPE(Test,1,0,0,MyTypeObject,MyTypeObject); +QML_DEFINE_TYPE(Test,1,0,0,MyContainer,MyContainer); +QML_DEFINE_TYPE(Test,1,0,0,MyPropertyValueSource,MyPropertyValueSource); +QML_DEFINE_TYPE(Test,1,0,0,MyDotPropertyObject,MyDotPropertyObject); diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp index eaa8267..92c23d4 100644 --- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp +++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp @@ -46,6 +46,9 @@ private slots: void customVariantTypes(); void valueTypes(); + void imports_data(); + void imports(); + // regression tests for crashes void crash1(); @@ -55,6 +58,8 @@ private: #define VERIFY_ERRORS(errorfile) \ if (!errorfile) { \ + if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \ + qWarning() << "Unexpected Errors:" << component.errors(); \ QVERIFY(!component.isError()); \ QVERIFY(component.errors().isEmpty()); \ } else { \ @@ -94,12 +99,12 @@ void tst_qmlparser::errors_data() QTest::addColumn("errorFile"); QTest::addColumn("create"); - QTest::newRow("nonExistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << false; - QTest::newRow("nonExistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << false; - QTest::newRow("nonExistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << false; - QTest::newRow("nonExistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << false; - QTest::newRow("nonExistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false; - QTest::newRow("nonExistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << false; + QTest::newRow("nonexistantProperty.1") << "nonexistantProperty.1.txt" << "nonexistantProperty.1.errors.txt" << false; + QTest::newRow("nonexistantProperty.2") << "nonexistantProperty.2.txt" << "nonexistantProperty.2.errors.txt" << false; + QTest::newRow("nonexistantProperty.3") << "nonexistantProperty.3.txt" << "nonexistantProperty.3.errors.txt" << false; + QTest::newRow("nonexistantProperty.4") << "nonexistantProperty.4.txt" << "nonexistantProperty.4.errors.txt" << false; + QTest::newRow("nonexistantProperty.5") << "nonexistantProperty.5.txt" << "nonexistantProperty.5.errors.txt" << false; + QTest::newRow("nonexistantProperty.6") << "nonexistantProperty.6.txt" << "nonexistantProperty.6.errors.txt" << false; QTest::newRow("wrongType (string for int)") << "wrongType.1.txt" << "wrongType.1.errors.txt" << false; QTest::newRow("wrongType (int for bool)") << "wrongType.2.txt" << "wrongType.2.errors.txt" << false; @@ -168,6 +173,7 @@ void tst_qmlparser::simpleObject() void tst_qmlparser::simpleContainer() { QmlComponent component(&engine, TEST_FILE("simpleContainer.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); QCOMPARE(container->children()->count(),2); @@ -176,6 +182,7 @@ void tst_qmlparser::simpleContainer() void tst_qmlparser::interfaceProperty() { QmlComponent component(&engine, TEST_FILE("interfaceProperty.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->interface()); @@ -185,6 +192,7 @@ void tst_qmlparser::interfaceProperty() void tst_qmlparser::interfaceQmlList() { QmlComponent component(&engine, TEST_FILE("interfaceQmlList.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); QVERIFY(container->qmllistAccessor().count() == 2); @@ -195,6 +203,7 @@ void tst_qmlparser::interfaceQmlList() void tst_qmlparser::interfaceQList() { QmlComponent component(&engine, TEST_FILE("interfaceQList.txt")); + VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); QVERIFY(container->qlistInterfaces()->count() == 2); @@ -205,6 +214,7 @@ void tst_qmlparser::interfaceQList() void tst_qmlparser::assignObjectToSignal() { QmlComponent component(&engine, TEST_FILE("assignObjectToSignal.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); @@ -214,6 +224,7 @@ void tst_qmlparser::assignObjectToSignal() void tst_qmlparser::assignObjectToVariant() { QmlComponent component(&engine, TEST_FILE("assignObjectToVariant.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVariant v = object->property("a"); @@ -223,6 +234,7 @@ void tst_qmlparser::assignObjectToVariant() void tst_qmlparser::assignLiteralSignalProperty() { QmlComponent component(&engine, TEST_FILE("assignLiteralSignalProperty.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->onLiteralSignal(), 10); @@ -232,6 +244,7 @@ void tst_qmlparser::assignLiteralSignalProperty() void tst_qmlparser::assignQmlComponent() { QmlComponent component(&engine, TEST_FILE("assignQmlComponent.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->children()->count() == 1); @@ -244,6 +257,7 @@ void tst_qmlparser::assignQmlComponent() void tst_qmlparser::assignBasicTypes() { QmlComponent component(&engine, TEST_FILE("assignBasicTypes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3); @@ -275,6 +289,7 @@ void tst_qmlparser::assignBasicTypes() void tst_qmlparser::assignTypeExtremes() { QmlComponent component(&engine, TEST_FILE("assignTypeExtremes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->uintProperty(), 0xEE6B2800); @@ -285,6 +300,7 @@ void tst_qmlparser::assignTypeExtremes() void tst_qmlparser::customParserTypes() { QmlComponent component(&engine, TEST_FILE("customParserTypes.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->property("count") == QVariant(2)); @@ -294,6 +310,7 @@ void tst_qmlparser::customParserTypes() void tst_qmlparser::rootAsQmlComponent() { QmlComponent component(&engine, TEST_FILE("rootAsQmlComponent.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); @@ -304,6 +321,7 @@ void tst_qmlparser::rootAsQmlComponent() void tst_qmlparser::inlineQmlComponents() { QmlComponent component(&engine, TEST_FILE("inlineQmlComponents.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->children()->count(), 1); @@ -318,6 +336,7 @@ void tst_qmlparser::inlineQmlComponents() void tst_qmlparser::idProperty() { QmlComponent component(&engine, TEST_FILE("idProperty.txt")); + VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->children()->count(), 1); @@ -332,6 +351,7 @@ void tst_qmlparser::idProperty() void tst_qmlparser::assignSignal() { QmlComponent component(&engine, TEST_FILE("assignSignal.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QTest::ignoreMessage(QtWarningMsg, "MyQmlObject::basicSlot"); @@ -342,6 +362,7 @@ void tst_qmlparser::assignSignal() void tst_qmlparser::dynamicProperties() { QmlComponent component(&engine, TEST_FILE("dynamicProperties.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("intProperty"), QVariant(10)); @@ -359,6 +380,7 @@ void tst_qmlparser::dynamicProperties() void tst_qmlparser::dynamicSignalsAndSlots() { QmlComponent component(&engine, TEST_FILE("dynamicSignalsAndSlots.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QVERIFY(object->metaObject()->indexOfMethod("signal1()") != -1); @@ -370,6 +392,7 @@ void tst_qmlparser::dynamicSignalsAndSlots() void tst_qmlparser::simpleBindings() { QmlComponent component(&engine, TEST_FILE("simpleBindings.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QCOMPARE(object->property("value1"), QVariant(10)); @@ -382,6 +405,7 @@ void tst_qmlparser::simpleBindings() void tst_qmlparser::autoComponentCreation() { QmlComponent component(&engine, TEST_FILE("autoComponentCreation.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QVERIFY(object->componentProperty() != 0); @@ -393,6 +417,7 @@ void tst_qmlparser::autoComponentCreation() void tst_qmlparser::propertyValueSource() { QmlComponent component(&engine, TEST_FILE("propertyValueSource.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QList valueSources = @@ -408,6 +433,7 @@ void tst_qmlparser::propertyValueSource() void tst_qmlparser::attachedProperties() { QmlComponent component(&engine, TEST_FILE("attachedProperties.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); QObject *attached = qmlAttachedPropertiesObject(object); @@ -419,6 +445,7 @@ void tst_qmlparser::attachedProperties() void tst_qmlparser::dynamicObjects() { QmlComponent component(&engine, TEST_FILE("dynamicObject.1.txt")); + VERIFY_ERRORS(0); QObject *object = component.create(); QVERIFY(object != 0); } @@ -427,6 +454,7 @@ void tst_qmlparser::dynamicObjects() void tst_qmlparser::customVariantTypes() { QmlComponent component(&engine, TEST_FILE("customVariantTypes.txt")); + VERIFY_ERRORS(0); MyQmlObject *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->customType().a, 10); @@ -435,6 +463,7 @@ void tst_qmlparser::customVariantTypes() void tst_qmlparser::valueTypes() { QmlComponent component(&engine, TEST_FILE("valueTypes.txt")); + VERIFY_ERRORS(0); MyTypeObject *object = qobject_cast(component.create()); QVERIFY(object != 0); @@ -457,6 +486,64 @@ void tst_qmlparser::valueTypes() QCOMPARE(p2.read(), QVariant(13)); } +class TestType : public QObject { + Q_OBJECT +public: + TestType(QObject *p=0) : QObject(p) {} +}; + +class TestType2 : public QObject { + Q_OBJECT +public: + TestType2(QObject *p=0) : QObject(p) {} +}; + +QML_DECLARE_TYPE(TestType) +QML_DECLARE_TYPE(TestType2) + +QML_DEFINE_TYPE(com.nokia.Test, 1, 0, 3, Test, TestType) +QML_DEFINE_TYPE(com.nokia.Test, 1, 5, 7, Test, TestType) +QML_DEFINE_TYPE(com.nokia.Test, 1, 8, 9, Test, TestType2) +QML_DEFINE_TYPE(com.nokia.Test, 1, 12, 13, Test, TestType2) +QML_DEFINE_TYPE(com.nokia.Test, 1, 9, 11, OldTest, TestType) + +void tst_qmlparser::imports_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("type"); + + QTest::newRow("missing import") << "Test {}" << ""; + QTest::newRow("not in version 0.0") << "import com.nokia.Test 0.0\nTest {}" << ""; + QTest::newRow("in version 1.0") << "import com.nokia.Test 1.0\nTest {}" << "TestType"; + QTest::newRow("in version 1.1") << "import com.nokia.Test 1.1\nTest {}" << "TestType"; + QTest::newRow("in version 1.3") << "import com.nokia.Test 1.3\nTest {}" << "TestType"; + QTest::newRow("not in version 1.4") << "import com.nokia.Test 1.4\nTest {}" << ""; + QTest::newRow("in version 1.5") << "import com.nokia.Test 1.5\nTest {}" << "TestType"; + QTest::newRow("changed in version 1.8") << "import com.nokia.Test 1.8\nTest {}" << "TestType2"; + QTest::newRow("not in version 1.10") << "import com.nokia.Test 1.10\nTest {}" << ""; + QTest::newRow("back in version 1.12") << "import com.nokia.Test 1.12\nTest {}" << "TestType2"; + QTest::newRow("old in version 1.9") << "import com.nokia.Test 1.9\nOldTest {}" << "TestType"; + QTest::newRow("old in version 1.11") << "import com.nokia.Test 1.11\nOldTest {}" << "TestType"; + QTest::newRow("no old in version 1.12") << "import com.nokia.Test 1.12\nOldTest {}" << ""; +} + +// Tests the registration of custom variant string converters +void tst_qmlparser::imports() +{ + QFETCH(QString, qml); + QFETCH(QString, type); + + QmlComponent component(&engine, qml.toUtf8(), TEST_FILE("empty.txt")); + + if (type.isEmpty()) { + QVERIFY(component.isError()); + } else { + QObject *object = component.create(); + QVERIFY(object != 0); + QCOMPARE(QString(object->metaObject()->className()), type); + } +} + void tst_qmlparser::crash1() { QmlComponent component(&engine, "Component {}"); diff --git a/tests/auto/declarative/qmlparser/unregisteredObject.txt b/tests/auto/declarative/qmlparser/unregisteredObject.txt index ff46457..9498e31 100644 --- a/tests/auto/declarative/qmlparser/unregisteredObject.txt +++ b/tests/auto/declarative/qmlparser/unregisteredObject.txt @@ -1 +1,2 @@ +import Test 1.0 UnregisteredObject {} diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt index 7ccfc75..3a90a7d 100644 --- a/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/unsupportedProperty.errors.txt @@ -1 +1 @@ -2:13:Invalid property assignment: unknown type QVariant::QMatrix +3:13:Invalid property assignment: unknown type QVariant::QMatrix diff --git a/tests/auto/declarative/qmlparser/unsupportedProperty.txt b/tests/auto/declarative/qmlparser/unsupportedProperty.txt index bbbd31d..9f19680 100644 --- a/tests/auto/declarative/qmlparser/unsupportedProperty.txt +++ b/tests/auto/declarative/qmlparser/unsupportedProperty.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { matrix: "1,0,0,0,1,0,0,0,1" } diff --git a/tests/auto/declarative/qmlparser/valueTypes.txt b/tests/auto/declarative/qmlparser/valueTypes.txt index 0d670af..bf325a7 100644 --- a/tests/auto/declarative/qmlparser/valueTypes.txt +++ b/tests/auto/declarative/qmlparser/valueTypes.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { rectProperty.x: 10 rectProperty.y: 11 diff --git a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt index 194da94..ba7a076 100644 --- a/tests/auto/declarative/qmlparser/wrongType.1.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.1.errors.txt @@ -1 +1 @@ -2:12:Invalid property assignment: int expected +3:12:Invalid property assignment: int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.1.txt b/tests/auto/declarative/qmlparser/wrongType.1.txt index 281a227..289d37f 100644 --- a/tests/auto/declarative/qmlparser/wrongType.1.txt +++ b/tests/auto/declarative/qmlparser/wrongType.1.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value: "hello" } diff --git a/tests/auto/declarative/qmlparser/wrongType.10.errors.txt b/tests/auto/declarative/qmlparser/wrongType.10.errors.txt index f391e2a..ae75b52 100644 --- a/tests/auto/declarative/qmlparser/wrongType.10.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.10.errors.txt @@ -1 +1 @@ -2:23:Invalid property assignment: datetime expected +3:23:Invalid property assignment: datetime expected diff --git a/tests/auto/declarative/qmlparser/wrongType.10.txt b/tests/auto/declarative/qmlparser/wrongType.10.txt index 07a90e0..2cf0e50 100644 --- a/tests/auto/declarative/qmlparser/wrongType.10.txt +++ b/tests/auto/declarative/qmlparser/wrongType.10.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { dateTimeProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.11.errors.txt b/tests/auto/declarative/qmlparser/wrongType.11.errors.txt index 9f5ebc9..23a4cda 100644 --- a/tests/auto/declarative/qmlparser/wrongType.11.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.11.errors.txt @@ -1 +1 @@ -2:20:Invalid property assignment: point expected +3:20:Invalid property assignment: point expected diff --git a/tests/auto/declarative/qmlparser/wrongType.11.txt b/tests/auto/declarative/qmlparser/wrongType.11.txt index 90a3797..ae77ba1 100644 --- a/tests/auto/declarative/qmlparser/wrongType.11.txt +++ b/tests/auto/declarative/qmlparser/wrongType.11.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { pointProperty: "apples" } diff --git a/tests/auto/declarative/qmlparser/wrongType.12.errors.txt b/tests/auto/declarative/qmlparser/wrongType.12.errors.txt index 4bbb2bf..3092100 100644 --- a/tests/auto/declarative/qmlparser/wrongType.12.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.12.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: size expected +3:19:Invalid property assignment: size expected diff --git a/tests/auto/declarative/qmlparser/wrongType.12.txt b/tests/auto/declarative/qmlparser/wrongType.12.txt index c3fa4a0..b7a366f 100644 --- a/tests/auto/declarative/qmlparser/wrongType.12.txt +++ b/tests/auto/declarative/qmlparser/wrongType.12.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { sizeProperty: "red" } diff --git a/tests/auto/declarative/qmlparser/wrongType.13.errors.txt b/tests/auto/declarative/qmlparser/wrongType.13.errors.txt index 194da94..ba7a076 100644 --- a/tests/auto/declarative/qmlparser/wrongType.13.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.13.errors.txt @@ -1 +1 @@ -2:12:Invalid property assignment: int expected +3:12:Invalid property assignment: int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.13.txt b/tests/auto/declarative/qmlparser/wrongType.13.txt index 075ec03..477aff1 100644 --- a/tests/auto/declarative/qmlparser/wrongType.13.txt +++ b/tests/auto/declarative/qmlparser/wrongType.13.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { value: "12" } diff --git a/tests/auto/declarative/qmlparser/wrongType.14.errors.txt b/tests/auto/declarative/qmlparser/wrongType.14.errors.txt index f90b8c6..d621fdd 100644 --- a/tests/auto/declarative/qmlparser/wrongType.14.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.14.errors.txt @@ -1 +1 @@ -2:21:Invalid property assignment: string expected +3:21:Invalid property assignment: string expected diff --git a/tests/auto/declarative/qmlparser/wrongType.14.txt b/tests/auto/declarative/qmlparser/wrongType.14.txt index 3d39c87..672d693 100644 --- a/tests/auto/declarative/qmlparser/wrongType.14.txt +++ b/tests/auto/declarative/qmlparser/wrongType.14.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { stringProperty: 10 } diff --git a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt index 4353165..9ff9f25 100644 --- a/tests/auto/declarative/qmlparser/wrongType.2.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.2.errors.txt @@ -1 +1 @@ -2:14:Invalid property assignment: boolean expected +3:14:Invalid property assignment: boolean expected diff --git a/tests/auto/declarative/qmlparser/wrongType.2.txt b/tests/auto/declarative/qmlparser/wrongType.2.txt index cdedf8c..34b74f7 100644 --- a/tests/auto/declarative/qmlparser/wrongType.2.txt +++ b/tests/auto/declarative/qmlparser/wrongType.2.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { enabled: 5 } diff --git a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt index 87b4eed..6d971c6 100644 --- a/tests/auto/declarative/qmlparser/wrongType.3.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.3.errors.txt @@ -1 +1 @@ -2:11:Invalid property assignment: rect expected +3:11:Invalid property assignment: rect expected diff --git a/tests/auto/declarative/qmlparser/wrongType.3.txt b/tests/auto/declarative/qmlparser/wrongType.3.txt index 839e0c7..384181a 100644 --- a/tests/auto/declarative/qmlparser/wrongType.3.txt +++ b/tests/auto/declarative/qmlparser/wrongType.3.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyQmlObject { rect: "5,5x10" } diff --git a/tests/auto/declarative/qmlparser/wrongType.4.errors.txt b/tests/auto/declarative/qmlparser/wrongType.4.errors.txt index 57a0744..ef34d0e 100644 --- a/tests/auto/declarative/qmlparser/wrongType.4.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.4.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: unknown enumeration +3:19:Invalid property assignment: unknown enumeration diff --git a/tests/auto/declarative/qmlparser/wrongType.4.txt b/tests/auto/declarative/qmlparser/wrongType.4.txt index 6fa4a9c..0787bf5 100644 --- a/tests/auto/declarative/qmlparser/wrongType.4.txt +++ b/tests/auto/declarative/qmlparser/wrongType.4.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { enumProperty: "InvalidEnumName" } diff --git a/tests/auto/declarative/qmlparser/wrongType.5.errors.txt b/tests/auto/declarative/qmlparser/wrongType.5.errors.txt index 0023d1d..cab10bd 100644 --- a/tests/auto/declarative/qmlparser/wrongType.5.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.5.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: unsigned int expected +3:19:Invalid property assignment: unsigned int expected diff --git a/tests/auto/declarative/qmlparser/wrongType.5.txt b/tests/auto/declarative/qmlparser/wrongType.5.txt index 95b0904..c50ae9a 100644 --- a/tests/auto/declarative/qmlparser/wrongType.5.txt +++ b/tests/auto/declarative/qmlparser/wrongType.5.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { uintProperty: -13 } diff --git a/tests/auto/declarative/qmlparser/wrongType.6.errors.txt b/tests/auto/declarative/qmlparser/wrongType.6.errors.txt index 06349e7..d0a0b00 100644 --- a/tests/auto/declarative/qmlparser/wrongType.6.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.6.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: double expected +3:19:Invalid property assignment: double expected diff --git a/tests/auto/declarative/qmlparser/wrongType.6.txt b/tests/auto/declarative/qmlparser/wrongType.6.txt index 78351f4..da10b78 100644 --- a/tests/auto/declarative/qmlparser/wrongType.6.txt +++ b/tests/auto/declarative/qmlparser/wrongType.6.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { realProperty: "Hello" } diff --git a/tests/auto/declarative/qmlparser/wrongType.7.errors.txt b/tests/auto/declarative/qmlparser/wrongType.7.errors.txt index e053f3b..614346b 100644 --- a/tests/auto/declarative/qmlparser/wrongType.7.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.7.errors.txt @@ -1 +1 @@ -2:20:Invalid property assignment: color expected +3:20:Invalid property assignment: color expected diff --git a/tests/auto/declarative/qmlparser/wrongType.7.txt b/tests/auto/declarative/qmlparser/wrongType.7.txt index 8279ffa..ddc3835 100644 --- a/tests/auto/declarative/qmlparser/wrongType.7.txt +++ b/tests/auto/declarative/qmlparser/wrongType.7.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { colorProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.8.errors.txt b/tests/auto/declarative/qmlparser/wrongType.8.errors.txt index b11f92b..1773c00 100644 --- a/tests/auto/declarative/qmlparser/wrongType.8.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.8.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: date expected +3:19:Invalid property assignment: date expected diff --git a/tests/auto/declarative/qmlparser/wrongType.8.txt b/tests/auto/declarative/qmlparser/wrongType.8.txt index e1cfe9a..a5f6756 100644 --- a/tests/auto/declarative/qmlparser/wrongType.8.txt +++ b/tests/auto/declarative/qmlparser/wrongType.8.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { dateProperty: 12 } diff --git a/tests/auto/declarative/qmlparser/wrongType.9.errors.txt b/tests/auto/declarative/qmlparser/wrongType.9.errors.txt index 419a5ce..8630975 100644 --- a/tests/auto/declarative/qmlparser/wrongType.9.errors.txt +++ b/tests/auto/declarative/qmlparser/wrongType.9.errors.txt @@ -1 +1 @@ -2:19:Invalid property assignment: time expected +3:19:Invalid property assignment: time expected diff --git a/tests/auto/declarative/qmlparser/wrongType.9.txt b/tests/auto/declarative/qmlparser/wrongType.9.txt index 84dfa66..a3db732 100644 --- a/tests/auto/declarative/qmlparser/wrongType.9.txt +++ b/tests/auto/declarative/qmlparser/wrongType.9.txt @@ -1,3 +1,4 @@ +import Test 1.0 MyTypeObject { timeProperty: 12 } -- cgit v0.12 From 28a76d03cd4f74d2619c8ab402fa97e71ce41310 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 5 Aug 2009 08:52:32 +1000 Subject: Get qmldebugger running, and add basic object/property view. --- src/declarative/debugger/qmldebug.cpp | 1 + src/declarative/qml/qmlenginedebug.cpp | 9 +- src/declarative/qml/qmlenginedebug_p.h | 1 + tools/qmldebugger/canvasscene.cpp | 248 --------------------------------- tools/qmldebugger/canvasscene.h | 43 ------ tools/qmldebugger/engine.cpp | 77 +++++++++- tools/qmldebugger/engine.h | 9 ++ tools/qmldebugger/engines.qml | 2 +- tools/qmldebugger/main.cpp | 4 - tools/qmldebugger/qmldebugger.pro | 4 +- tools/tools.pro | 2 +- 11 files changed, 93 insertions(+), 307 deletions(-) delete mode 100644 tools/qmldebugger/canvasscene.cpp delete mode 100644 tools/qmldebugger/canvasscene.h diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 8309ec6..9397bb9 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -103,6 +103,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, ds >> data; QmlDebugPropertyReference prop; prop.m_name = data.name; + prop.m_binding = data.binding; if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic) prop.m_value = data.value; else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) { diff --git a/src/declarative/qml/qmlenginedebug.cpp b/src/declarative/qml/qmlenginedebug.cpp index 2b8aac3..c26f3b7 100644 --- a/src/declarative/qml/qmlenginedebug.cpp +++ b/src/declarative/qml/qmlenginedebug.cpp @@ -44,6 +44,8 @@ #include #include #include +#include +#include #include "qmlcontext_p.h" QT_BEGIN_NAMESPACE @@ -73,7 +75,7 @@ QDataStream &operator>>(QDataStream &ds, QDataStream &operator<<(QDataStream &ds, const QmlEngineDebugServer::QmlObjectProperty &data) { - ds << (int)data.type << data.name << data.value; + ds << (int)data.type << data.name << data.value << data.binding; return ds; } @@ -81,7 +83,7 @@ QDataStream &operator>>(QDataStream &ds, QmlEngineDebugServer::QmlObjectProperty &data) { int type; - ds >> type >> data.name >> data.value; + ds >> type >> data.name >> data.value >> data.binding; data.type = (QmlEngineDebugServer::QmlObjectProperty::Type)type; return ds; } @@ -95,6 +97,9 @@ QmlEngineDebugServer::propertyData(QObject *obj, int propIdx) rv.type = QmlObjectProperty::Unknown; rv.name = prop.name(); + QmlBinding *binding = QmlMetaProperty(obj, rv.name).binding(); + if (binding) + rv.binding = binding->expression(); if (prop.type() < QVariant::UserType) { rv.type = QmlObjectProperty::Basic; diff --git a/src/declarative/qml/qmlenginedebug_p.h b/src/declarative/qml/qmlenginedebug_p.h index e85ab6f..87b2ffd 100644 --- a/src/declarative/qml/qmlenginedebug_p.h +++ b/src/declarative/qml/qmlenginedebug_p.h @@ -81,6 +81,7 @@ public: Type type; QString name; QVariant value; + QString binding; }; static void addEngine(QmlEngine *); diff --git a/tools/qmldebugger/canvasscene.cpp b/tools/qmldebugger/canvasscene.cpp deleted file mode 100644 index 65db9da..0000000 --- a/tools/qmldebugger/canvasscene.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "canvasscene.h" -#include -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class CanvasSceneClientPlugin : public QmlDebugClient -{ -public: - CanvasSceneClientPlugin(QmlDebugConnection *, CanvasScene *s); - -protected: - void messageReceived(const QByteArray &); - -private: - void dump(QDataStream &, int indent); - CanvasScene *scene; -}; - -class QmlCanvasDebuggerItem : public QTreeWidgetItem -{ -public: - QmlCanvasDebuggerItem(QTreeWidget *tree) - : QTreeWidgetItem(tree), me(0), img(0) - { - } - - QmlCanvasDebuggerItem(QTreeWidgetItem *item) - : QTreeWidgetItem(item), me(0), img(0) - { - } - - QFxRect *me; - QFxImage *img; -}; - -CanvasSceneClientPlugin::CanvasSceneClientPlugin(QmlDebugConnection *c, - CanvasScene *s) -: QmlDebugClient(QLatin1String("CanvasScene"), c), scene(s) -{ -} - -void CanvasSceneClientPlugin::messageReceived(const QByteArray &data) -{ - QByteArray d = data; - QDataStream ds(&d, QIODevice::ReadOnly); - - scene->message(ds); -} - -void CanvasScene::message(QDataStream &ds) -{ - QList children = m_canvasRoot->children(); - qDeleteAll(children); - m_tree->clear(); - m_selected = 0; - - QTreeWidgetItem *root = new QmlCanvasDebuggerItem(m_tree); - root->setText(0, tr("Root")); - root->setExpanded(true); - clone(root, m_canvasRoot, ds); -} - -void CanvasScene::clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, - QDataStream &ds) -{ - int children; - ds >> children; - - for (int ii = 0; ii < children; ++ii) { - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix; - - QmlCanvasDebuggerItem *childItem = new QmlCanvasDebuggerItem(item); - childItem->setText(0, name); - childItem->setExpanded(true); - - QFxRect *rect = new QFxRect; - rect->setParent(me); - rect->setX(x); - rect->setY(y); - rect->setZ(z); - rect->setWidth(width); - rect->setHeight(height); - rect->setTransformOrigin((QSimpleCanvasItem::TransformOrigin)transformOrigin); - rect->setScale(scale); - rect->setFlip((QSimpleCanvasItem::Flip)flip); - rect->setTransform(transform); - - if (activeFocus) - rect->setColor(QColor(0, 0, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusPanel) - rect->setColor(QColor(0, 255, 0, 10)); - else if(options & QSimpleCanvasItem::IsFocusRealm) - rect->setColor(QColor(0, 0, 255, 10)); - else - rect->setColor(QColor(255, 0, 0, 10)); - - if (pix.width() > 0 || pix.height() > 0) { - QFxImage *img = new QFxImage; - img->setParent(rect); - img->setWidth(width); - img->setHeight(height); - img->setPixmap(pix); - img->setOpacity(0); - childItem->img = img; - } - - childItem->me = rect; - - clone(childItem, rect, ds); - } -} - -void CanvasSceneClientPlugin::dump(QDataStream &ds, int indent) -{ - QString name; - qreal x, y, z, width, height, scale; - QTransform transform; - bool activeFocus; - int transformOrigin, flip, options, count; - QPixmap pix; - - ds >> name >> x >> y >> z >> width >> height >> transformOrigin >> scale - >> flip >> transform >> activeFocus >> options >> pix >> count; - - QByteArray ba(indent * 4, ' '); - qWarning() << ba.constData() << name << x << y; - - for(int ii = 0; ii < count; ++ii) - dump(ds, indent + 1); -} - -CanvasScene::CanvasScene(QmlDebugConnection *c, QWidget *parent) -: QWidget(parent) -{ - client = new CanvasSceneClientPlugin(c, this); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0,0,0,0); - layout->setSpacing(0); - setLayout(layout); - QSplitter *splitter = new QSplitter(this); - - m_tree = new QTreeWidget(this); - m_tree->setHeaderHidden(true); - QObject::connect(m_tree, SIGNAL(itemExpanded(QTreeWidgetItem*)), - this, SLOT(itemExpanded(QTreeWidgetItem*))); - QObject::connect(m_tree, SIGNAL(itemCollapsed(QTreeWidgetItem*)), - this, SLOT(itemCollapsed(QTreeWidgetItem*))); - QObject::connect(m_tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)), - this, SLOT(itemClicked(QTreeWidgetItem*))); - m_canvas = new QSimpleCanvas(QSimpleCanvas::SimpleCanvas, this); - m_canvasRoot = new QSimpleCanvasItem; - m_canvasRoot->setParent(m_canvas->root()); - splitter->addWidget(m_tree); - splitter->addWidget(m_canvas); - splitter->setStretchFactor(1, 2); - layout->addWidget(splitter); - - QHBoxLayout *hlayout = new QHBoxLayout; - hlayout->setContentsMargins(0,0,0,0); - hlayout->addStretch(2); - hlayout->setSpacing(0); - layout->addLayout(hlayout); - QSpinBox *x = new QSpinBox(this); - x->setSingleStep(50); - x->setMaximum(10000); - x->setMinimum(-10000); - QObject::connect(x, SIGNAL(valueChanged(int)), this, SLOT(setX(int))); - QSpinBox *y = new QSpinBox(this); - y->setSingleStep(50); - y->setMaximum(10000); - y->setMinimum(-10000); - QObject::connect(y, SIGNAL(valueChanged(int)), this, SLOT(setY(int))); - hlayout->addWidget(x); - hlayout->addWidget(y); - QPushButton *pb = new QPushButton(tr("Refresh"), this); - QObject::connect(pb, SIGNAL(clicked()), this, SLOT(refresh())); - hlayout->addWidget(pb); -} - -void CanvasScene::refresh() -{ - client->sendMessage(QByteArray()); -} - -void CanvasScene::itemExpanded(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->me) - item->me->setOpacity(1); -} - -void CanvasScene::setOpacityRecur(QTreeWidgetItem *i, qreal op) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->img) - item->img->setOpacity(op); - - for(int ii = 0; ii < item->childCount(); ++ii) - setOpacityRecur(item->child(ii), op); -} - -void CanvasScene::itemClicked(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - - if(m_selected) { - setOpacityRecur(m_selected, 0); - m_selected = 0; - } - - m_selected = item; - setOpacityRecur(m_selected, 1); -} - -void CanvasScene::itemCollapsed(QTreeWidgetItem *i) -{ - QmlCanvasDebuggerItem *item = static_cast(i); - if(item->me) - item->me->setOpacity(0); -} - -void CanvasScene::setX(int x) -{ - m_canvasRoot->setX(x); -} - -void CanvasScene::setY(int y) -{ - m_canvasRoot->setY(y); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/canvasscene.h b/tools/qmldebugger/canvasscene.h deleted file mode 100644 index 8c6b8d5..0000000 --- a/tools/qmldebugger/canvasscene.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef CANVASSCENE_H -#define CANVASSCENE_H - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlDebugConnection; -class CanvasSceneClient; -class QmlDebugClient; -class CanvasScene : public QWidget -{ -Q_OBJECT -public: - CanvasScene(QmlDebugConnection *, QWidget *parent = 0); - - void message(QDataStream &); -private slots: - void refresh(); - void itemClicked(QTreeWidgetItem *); - void itemExpanded(QTreeWidgetItem *); - void itemCollapsed(QTreeWidgetItem *); - void setX(int); - void setY(int); - -private: - void setOpacityRecur(QTreeWidgetItem *, qreal); - void clone(QTreeWidgetItem *item, QSimpleCanvasItem *me, QDataStream &); - QmlDebugClient *client; - - QTreeWidget *m_tree; - QSimpleCanvas *m_canvas; - QSimpleCanvasItem *m_canvasRoot; - QTreeWidgetItem *m_selected; -}; - -QT_END_NAMESPACE - -#endif // CANVASSCENE_H - diff --git a/tools/qmldebugger/engine.cpp b/tools/qmldebugger/engine.cpp index 3b8c8b1..229cd3f 100644 --- a/tools/qmldebugger/engine.cpp +++ b/tools/qmldebugger/engine.cpp @@ -2,7 +2,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -11,9 +14,9 @@ QT_BEGIN_NAMESPACE class DebuggerEngineItem : public QObject { -Q_OBJECT -Q_PROPERTY(QString name READ name CONSTANT); -Q_PROPERTY(QString engineId READ engineId CONSTANT); + Q_OBJECT + Q_PROPERTY(QString name READ name CONSTANT); + Q_PROPERTY(int engineId READ engineId CONSTANT); public: DebuggerEngineItem(const QString &name, int id) @@ -56,7 +59,23 @@ EnginePane::EnginePane(QmlDebugConnection *client, QWidget *parent) QObject::connect(query, SIGNAL(clicked()), this, SLOT(fetchClicked())); layout->addWidget(query); - layout->addStretch(10); + QHBoxLayout *hbox = new QHBoxLayout; + hbox->setContentsMargins(0, 0, 0, 0); + + m_objTree = new QTreeWidget(this); + m_objTree->setHeaderHidden(true); + connect(m_objTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(itemClicked(QTreeWidgetItem *))); + hbox->addWidget(m_objTree); + + m_propTable = new QTableWidget(this); + m_propTable->setColumnCount(2); + m_propTable->setColumnWidth(0, 150); + m_propTable->setColumnWidth(1, 400); + m_propTable->setHorizontalHeaderLabels(QStringList() << "name" << "value"); + hbox->addWidget(m_propTable); + hbox->setStretchFactor(m_propTable, 2); + + layout->addLayout(hbox); } void EnginePane::engineSelected(int id) @@ -65,6 +84,40 @@ void EnginePane::engineSelected(int id) queryContext(id); } +void EnginePane::itemClicked(QTreeWidgetItem *item) +{ + m_propTable->clearContents(); + + if (m_object) { + delete m_object; + m_object = 0; + } + + m_object = m_client.queryObjectRecursive(QmlDebugObjectReference(item->data(0, Qt::UserRole).toInt()), this); + if (!m_object->isWaiting()) + showProperties(); + else + QObject::connect(m_object, SIGNAL(stateChanged(State)), + this, SLOT(showProperties())); +} + +void EnginePane::showProperties() +{ + QmlDebugObjectReference obj = m_object->object(); + m_propTable->setRowCount(obj.properties().count()); + for (int ii = 0; ii < obj.properties().count(); ++ii) { + QTableWidgetItem *name = new QTableWidgetItem(obj.properties().at(ii).name()); + m_propTable->setItem(ii, 0, name); + QTableWidgetItem *value; + if (!obj.properties().at(ii).binding().isEmpty()) + value = new QTableWidgetItem(obj.properties().at(ii).binding()); + else + value = new QTableWidgetItem(obj.properties().at(ii).value().toString()); + m_propTable->setItem(ii, 1, value); + } + delete m_object; m_object = 0; +} + void EnginePane::queryContext(int id) { if (m_context) { @@ -110,6 +163,17 @@ void EnginePane::dump(const QmlDebugObjectReference &obj, int ind) dump(obj.children().at(ii), ind + 1); } + +void EnginePane::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) +{ + QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(m_objTree); + item->setText(0, obj.className()); + item->setData(0, Qt::UserRole, obj.debugId()); + + for (int ii = 0; ii < obj.children().count(); ++ii) + buildTree(obj.children().at(ii), item); +} + void EnginePane::queryEngines() { if (m_engines) @@ -131,8 +195,8 @@ void EnginePane::enginesChanged() QList engines = m_engines->engines(); delete m_engines; m_engines = 0; - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), + for (int ii = 0; ii < engines.count(); ++ii) + m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), engines.at(ii).debugId()); m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); @@ -162,6 +226,7 @@ void EnginePane::fetchObject(int id) void EnginePane::objectFetched() { dump(m_object->object(), 0); + buildTree(m_object->object(), 0); delete m_object; m_object = 0; } diff --git a/tools/qmldebugger/engine.h b/tools/qmldebugger/engine.h index a713f25..52f0608 100644 --- a/tools/qmldebugger/engine.h +++ b/tools/qmldebugger/engine.h @@ -12,6 +12,9 @@ QT_BEGIN_NAMESPACE class QmlDebugConnection; class EngineClientPlugin; class QLineEdit; +class QTreeWidget; +class QTreeWidgetItem; +class QTableWidget; class EnginePane : public QWidget { Q_OBJECT @@ -31,9 +34,13 @@ private slots: void engineSelected(int); + void itemClicked(QTreeWidgetItem *); + void showProperties(); + private: void dump(const QmlDebugContextReference &, int); void dump(const QmlDebugObjectReference &, int); + void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); QmlEngineDebug m_client; QmlDebugEnginesQuery *m_engines; @@ -41,6 +48,8 @@ private: QmlDebugObjectQuery *m_object; QLineEdit *m_text; + QTreeWidget *m_objTree; + QTableWidget *m_propTable; QFxView *m_engineView; QList m_engineItems; diff --git a/tools/qmldebugger/engines.qml b/tools/qmldebugger/engines.qml index fc364e2..eedba08 100644 --- a/tools/qmldebugger/engines.qml +++ b/tools/qmldebugger/engines.qml @@ -19,7 +19,7 @@ Item { } Text { anchors.top: Image.bottom; - text: modelData.name + "(" + modelData.engineId + ")" + text: modelData.name + "(" + modelData.engineId + ")" anchors.horizontalCenter: parent.horizontalCenter } MouseRegion { diff --git a/tools/qmldebugger/main.cpp b/tools/qmldebugger/main.cpp index 500836f..a37a437 100644 --- a/tools/qmldebugger/main.cpp +++ b/tools/qmldebugger/main.cpp @@ -8,7 +8,6 @@ #include #include #include "canvasframerate.h" -#include "canvasscene.h" #include "engine.h" #include #include @@ -75,9 +74,6 @@ Shell::Shell(QWidget *parent) CanvasFrameRate *cfr = new CanvasFrameRate(&client, this); tabs->addTab(cfr, tr("Frame Rate")); - CanvasScene *cs = new CanvasScene(&client, this); - tabs->addTab(cs, tr("Scene")); - EnginePane *ep = new EnginePane(&client, this); tabs->addTab(ep, tr("QML Engine")); diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro index 1068858..532fd2a 100644 --- a/tools/qmldebugger/qmldebugger.pro +++ b/tools/qmldebugger/qmldebugger.pro @@ -3,8 +3,8 @@ QT += network declarative contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl # Input -HEADERS += canvasframerate.h canvasscene.h engine.h -SOURCES += main.cpp canvasframerate.cpp canvasscene.cpp engine.cpp +HEADERS += canvasframerate.h engine.h +SOURCES += main.cpp canvasframerate.cpp engine.cpp target.path=$$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/tools.pro b/tools/tools.pro index ecdbcd1..68b4801 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -24,7 +24,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf -- cgit v0.12