diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-12-05 14:10:59 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-05 15:33:39 +0100 |
commit | 97cbef99cbd35b22a17bf29ed406b20d4d35680c (patch) | |
tree | 681c29a045fa08da107015a994c6a0f40b6c95ca /src/declarative/qml/qdeclarativecompiler.cpp | |
parent | 5ac2990688c7da6ce872bccc5c08129267887d68 (diff) |
Fix crash when QtQuick 2.0 wasn't imported
The QML compiler still tried to resolve the implicit "Component" element
within the QtQuick 2.0 namespace.
Task-number: QTBUG-23017
Change-Id: I62ae962f58787910a76f76c872daa08874b5df56
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src/declarative/qml/qdeclarativecompiler.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index aa27d7994f..5500efa42f 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -90,12 +90,14 @@ static QString id_string(QLatin1String("id")); static QString on_string(QLatin1String("on")); static QString Changed_string(QLatin1String("Changed")); static QString Component_string(QLatin1String("Component")); +static QString Component_import_string(QLatin1String("QML/Component")); /*! Instantiate a new QDeclarativeCompiler. */ QDeclarativeCompiler::QDeclarativeCompiler(QDeclarativePool *pool) -: pool(pool), output(0), engine(0), unitRoot(0), unit(0), componentStats(0) +: pool(pool), output(0), engine(0), unitRoot(0), unit(0), cachedComponentTypeRef(-1), + componentStats(0) { if (compilerStatDump()) componentStats = pool->New<ComponentStats>(); @@ -829,6 +831,7 @@ bool QDeclarativeCompiler::compile(QDeclarativeEngine *engine, this->engine = 0; this->enginePrivate = 0; this->unit = 0; + this->cachedComponentTypeRef = -1; this->unitRoot = 0; return !isError(); @@ -1586,16 +1589,21 @@ bool QDeclarativeCompiler::buildSubObject(QDeclarativeScript::Object *obj, const int QDeclarativeCompiler::componentTypeRef() { - QDeclarativeType *t = QDeclarativeMetaType::qmlType(QLatin1String("QtQuick/Component"),2,0); - for (int ii = output->types.count() - 1; ii >= 0; --ii) { - if (output->types.at(ii).type == t) - return ii; + if (cachedComponentTypeRef == -1) { + QDeclarativeType *t = QDeclarativeMetaType::qmlType(Component_import_string,1,0); + for (int ii = output->types.count() - 1; ii >= 0; --ii) { + if (output->types.at(ii).type == t) { + cachedComponentTypeRef = ii; + return ii; + } + } + QDeclarativeCompiledData::TypeReference ref; + ref.className = Component_string; + ref.type = t; + output->types << ref; + cachedComponentTypeRef = output->types.count() - 1; } - QDeclarativeCompiledData::TypeReference ref; - ref.className = Component_string; - ref.type = t; - output->types << ref; - return output->types.count() - 1; + return cachedComponentTypeRef; } bool QDeclarativeCompiler::buildSignal(QDeclarativeScript::Property *prop, QDeclarativeScript::Object *obj, |