aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/qml')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp5
-rw-r--r--src/qml/qml/qqmlscript.cpp2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp25
-rw-r--r--src/qml/qml/qqmltypeloader_p.h1
4 files changed, 31 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index 4e70e14894..56776dcb82 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -1239,6 +1239,11 @@ QObject *QmlObjectCreator::createInstance(int index, QObject *parent)
}
} else {
Q_ASSERT(typeRef.component);
+ if (typeRef.component->qmlUnit->isSingleton())
+ {
+ recordError(obj->location, tr("Composite Singleton Type %1 is not creatable").arg(stringAt(obj->inheritedTypeNameIndex)));
+ return 0;
+ }
QmlObjectCreator subCreator(context, typeRef.component);
instance = subCreator.create();
if (!instance) {
diff --git a/src/qml/qml/qqmlscript.cpp b/src/qml/qml/qqmlscript.cpp
index cc01307e54..9fd06aa934 100644
--- a/src/qml/qml/qqmlscript.cpp
+++ b/src/qml/qml/qqmlscript.cpp
@@ -895,7 +895,7 @@ bool ProcessAST::visit(AST::UiPragma *node)
// For now the only valid pragma is Singleton, so lets validate the input
if (!node->pragmaType->name.isNull())
{
- if (QLatin1String("Singleton") == node->pragmaType->name.toString())
+ if (QLatin1String("Singleton") == node->pragmaType->name)
{
pragma.type = QQmlScript::Pragma::Singleton;
} else {
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 932faf4b88..601c1b8bdc 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2218,7 +2218,24 @@ void QQmlTypeData::dataReceived(const Data &data)
}
}
- foreach (const QQmlScript::Pragma &pragma, scriptParser.pragmas()) {
+ // ### convert to use new data structure once old compiler is gone.
+ if (m_useNewCompiler && m_newPragmas.isEmpty()) {
+ m_newPragmas.reserve(parsedQML->pragmas.size());
+ foreach (QtQml::Pragma *p, parsedQML->pragmas) {
+ QQmlScript::Pragma pragma;
+ pragma.location.start.line = p->location.line;
+ pragma.location.start.column = p->location.column;
+
+ switch (p->type) {
+ case QtQml::Pragma::PragmaSingleton: pragma.type = QQmlScript::Pragma::Singleton; break;
+ default: break;
+ }
+
+ m_newPragmas << pragma;
+ }
+ }
+
+ foreach (const QQmlScript::Pragma &pragma, m_useNewCompiler ? m_newPragmas : scriptParser.pragmas()) {
if (!addPragma(pragma, &errors)) {
Q_ASSERT(errors.size());
setError(errors);
@@ -2280,6 +2297,12 @@ void QQmlTypeData::compile()
foreach (const QString &ns, m_namespaces)
m_compiledData->importCache->add(ns);
+ // Add any Composite Singletons that were used to the import cache
+ for (int i = 0; i < compositeSingletons().count(); ++i) {
+ m_compiledData->importCache->add(compositeSingletons().at(i).type->qmlTypeName(),
+ compositeSingletons().at(i).type->sourceUrl(), compositeSingletons().at(i).prefix);
+ }
+
m_imports.populateCache(m_compiledData->importCache);
m_compiledData->importCache->addref();
diff --git a/src/qml/qml/qqmltypeloader_p.h b/src/qml/qml/qqmltypeloader_p.h
index b9bf056cb3..b93cf2942d 100644
--- a/src/qml/qml/qqmltypeloader_p.h
+++ b/src/qml/qml/qqmltypeloader_p.h
@@ -460,6 +460,7 @@ private:
// --- new compiler
QScopedPointer<QtQml::ParsedQML> parsedQML;
QList<QQmlScript::Import> m_newImports;
+ QList<QQmlScript::Pragma> m_newPragmas;
// ---
QList<ScriptReference> m_scripts;