aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-05-21 10:34:29 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-26 21:28:35 +0200
commit91a0f71783df5482af27ab2d61fed8be70351205 (patch)
tree3ae3f9b65c5d1ac875fe27fa9ff8110e3cef1fa3 /src
parent209e55cb1075a6d1698640cd96562856b97fa9be (diff)
Fix crash when sharing data structures between 32-bit and 64-bit
The data structures in QV4::CompiledData are intended to be shareable between different architectures (if endianness is the same). This requires us to pack them, which is possible with MSVC and GCC (which also includes clang) Change-Id: I078254b9d314f60f8973a0c9404f53af41a48fb8 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/compiler/qv4compileddata_p.h54
-rw-r--r--src/quick/util/qquickpropertychanges.cpp6
2 files changed, 36 insertions, 24 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index 6ee23690a6..5fb94af140 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -69,6 +69,10 @@ struct Function;
struct Lookup;
struct RegExp;
+#if defined(Q_CC_MSVC) || defined(Q_CC_GNU)
+#pragma pack(push, 1)
+#endif
+
struct Location
{
qint32 line;
@@ -82,29 +86,6 @@ struct Location
}
};
-struct TypeReference
-{
- TypeReference(const Location &loc)
- : location(loc)
- , needsCreation(false)
- , errorWhenNotFound(false)
- {}
- Location location; // first use
- bool needsCreation : 1; // whether the type needs to be creatable or not
- bool errorWhenNotFound: 1;
-};
-
-// map from name index to location of first use
-struct TypeReferenceMap : QHash<int, TypeReference>
-{
- TypeReference &add(int nameIndex, const Location &loc) {
- Iterator it = find(nameIndex);
- if (it != end())
- return *it;
- return *insert(nameIndex, loc);
- }
-};
-
struct RegExp
{
enum Flags {
@@ -553,6 +534,33 @@ struct QmlUnit
}
};
+#if defined(Q_CC_MSVC) || defined(Q_CC_GNU)
+#pragma pack(pop)
+#endif
+
+struct TypeReference
+{
+ TypeReference(const Location &loc)
+ : location(loc)
+ , needsCreation(false)
+ , errorWhenNotFound(false)
+ {}
+ Location location; // first use
+ bool needsCreation : 1; // whether the type needs to be creatable or not
+ bool errorWhenNotFound: 1;
+};
+
+// map from name index to location of first use
+struct TypeReferenceMap : QHash<int, TypeReference>
+{
+ TypeReference &add(int nameIndex, const Location &loc) {
+ Iterator it = find(nameIndex);
+ if (it != end())
+ return *it;
+ return *insert(nameIndex, loc);
+ }
+};
+
// This is how this hooks into the existing structures:
//VM::Function
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 1a631703fb..882ad66891 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -324,7 +324,11 @@ void QQuickPropertyChangesPrivate::decode()
ds >> id;
} else if (type == QV4::CompiledData::Binding::Type_Translation
|| type == QV4::CompiledData::Binding::Type_TranslationById) {
- ds >> tsd.commentIndex >> tsd.number;
+ quint32 commentIndex;
+ qint32 number;
+ ds >> commentIndex >> number;
+ tsd.commentIndex = commentIndex;
+ tsd.number = number;
}
ds >> data;