summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-12 04:15:08 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-12 04:15:08 (GMT)
commit24653fc546fe8150ebca1c44c36fe17c36527cc7 (patch)
treea5946ba6011396a543694de475537fe3abc2ced1
parent1ea93870fce7ff032053775fb19d42e950dd5ccb (diff)
downloadQt-24653fc546fe8150ebca1c44c36fe17c36527cc7.zip
Qt-24653fc546fe8150ebca1c44c36fe17c36527cc7.tar.gz
Qt-24653fc546fe8150ebca1c44c36fe17c36527cc7.tar.bz2
Test that Component {} is allowed as the root element
-rw-r--r--src/declarative/qml/qmlcompiler.cpp6
-rw-r--r--tests/auto/declarative/qmllanguage/data/ComponentComposite.qml5
-rw-r--r--tests/auto/declarative/qmllanguage/data/componentCompositeType.qml8
-rw-r--r--tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp10
4 files changed, 27 insertions, 2 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 6d1df6d..023903d 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -672,7 +672,7 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
obj->className = tr.className;
// This object is a "Component" element
- if (obj->metatype == &QmlComponent::staticMetaObject) {
+ if (tr.type && obj->metatype == &QmlComponent::staticMetaObject) {
COMPILE_CHECK(buildComponent(obj, ctxt));
return true;
}
@@ -786,7 +786,9 @@ bool QmlCompiler::buildObject(Object *obj, const BindingContext &ctxt)
void QmlCompiler::genObject(QmlParser::Object *obj)
{
- if (obj->metatype == &QmlComponent::staticMetaObject) {
+ const QmlCompiledData::TypeReference &tr =
+ output->types.at(obj->type);
+ if (tr.type && obj->metatype == &QmlComponent::staticMetaObject) {
genComponent(obj);
return;
}
diff --git a/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml b/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml
new file mode 100644
index 0000000..f8726ef
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/ComponentComposite.qml
@@ -0,0 +1,5 @@
+import Qt 4.6
+
+Component {
+ Object {}
+}
diff --git a/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml b/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml
new file mode 100644
index 0000000..3a1b191
--- /dev/null
+++ b/tests/auto/declarative/qmllanguage/data/componentCompositeType.qml
@@ -0,0 +1,8 @@
+import Qt 4.6
+
+Object {
+ property var test
+
+ test: ComponentComposite {}
+}
+
diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
index 94998c7..a991144 100644
--- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
+++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp
@@ -57,6 +57,7 @@ private slots:
void valueTypes();
void cppnamespace();
void aliasProperties();
+ void componentCompositeType();
void importsBuiltin_data();
void importsBuiltin();
@@ -657,6 +658,15 @@ void tst_qmllanguage::aliasProperties()
}
}
+// Test that the root element in a composite type can be a Component
+void tst_qmllanguage::componentCompositeType()
+{
+ QmlComponent component(&engine, TEST_FILE("componentCompositeType.qml"));
+ VERIFY_ERRORS(0);
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+}
+
class TestType : public QObject {
Q_OBJECT
public: