aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compileddata_p.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-27 16:55:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-29 10:08:50 +0100
commit3d3429f55bca1b09c1d2184ef719abae0e762a09 (patch)
treefbf79751ef8c18bfa594667c9c0d3c62d986e06b /src/qml/compiler/qv4compileddata_p.h
parent7cfd7ab2b1244681e384ec4640ee6e528881f4af (diff)
[new compiler] Avoid uncreatable type errors for types that aren't created
QtQuick.Keys for example is not creatable, but it's also never created but only used as attached properties. Therefore types used as attached properties create the needCreation = false flag in the referenced types. Change-Id: I6ca3a3ff677858bf3c55d3e08a0f0fc8ee9160fe Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qv4compileddata_p.h')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 06361fbf85..29b6fd564e 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -74,13 +74,24 @@ struct Location
qint32 column;
};
+struct TypeReference
+{
+ TypeReference(const Location &loc)
+ : location(loc)
+ , needsCreation(false)
+ {}
+ Location location; // first use
+ bool needsCreation; // whether the type needs to be creatable or not
+};
+
// map from name index to location of first use
-struct TypeReferenceMap : QHash<int, Location>
+struct TypeReferenceMap : QHash<int, TypeReference>
{
- void add(int nameIndex, const Location &loc) {
- if (contains(nameIndex))
- return;
- insert(nameIndex, loc);
+ TypeReference &add(int nameIndex, const Location &loc) {
+ Iterator it = find(nameIndex);
+ if (it != end())
+ return *it;
+ return *insert(nameIndex, loc);
}
};