diff options
author | Robin Burchell <robin.burchell@jollamobile.com> | 2012-12-05 02:12:30 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-12-12 00:37:41 +0100 |
commit | 6d7d47551de18509a382185e1216632f3d862f01 (patch) | |
tree | 036489386a42fba4009772c24700f335380daeb4 /src | |
parent | cae858768f7d16b79f3627cd5b077da89dc0c7c9 (diff) |
Process imports in the order they appear in the code.
By placing imports into a hash keyed by the qualifier, imports were not
processed in the order they appeared in the source. This is perhaps not a major
problem, but it is nice to have predictability.
This becomes more important in Qt 5, when QHash is randomly seeded at
application startup, as alterations to order could have strange side effects on
code.
Reported-by: Maciej Blomberg
Change-Id: Ibd34fab1eed4bc727b498ba4684c62d801ae713b
Reviewed-by: Matthew Vogt <matthew.vogt@qinetic.com.au>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativecompiler.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index f73de7f3..ab321203 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -662,7 +662,8 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree) output->bytecode << init; // Build global import scripts - QHash<QString, Object::ScriptBlock> importedScripts; + QSet<QString> importedScripts; + QList<Object::ScriptBlock> importedScriptList; QStringList importedScriptIndexes; foreach (const QDeclarativeTypeData::ScriptReference &script, unit->resolvedScripts()) { @@ -672,24 +673,23 @@ void QDeclarativeCompiler::compileTree(QDeclarativeParser::Object *tree) Q_ASSERT(!importedScripts.contains(script.qualifier)); if (!scriptCode.isEmpty()) { - Object::ScriptBlock &scriptBlock = importedScripts[script.qualifier]; + importedScripts.insert(script.qualifier); + Object::ScriptBlock scriptBlock; scriptBlock.code = scriptCode; scriptBlock.file = script.script->finalUrl().toString(); scriptBlock.pragmas = pragmas; + importedScriptList.append(scriptBlock); + importedScriptIndexes.append(script.qualifier); } } - for (QHash<QString, Object::ScriptBlock>::Iterator iter = importedScripts.begin(); - iter != importedScripts.end(); ++iter) { - - importedScriptIndexes.append(iter.key()); - + for (int i = 0; i < importedScriptList.count(); ++i) { QDeclarativeInstruction import; import.type = QDeclarativeInstruction::StoreImportedScript; import.line = 0; import.storeScript.value = output->scripts.count(); - output->scripts << *iter; + output->scripts << importedScriptList.at(i); output->bytecode << import; } |