aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4property_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-03-10 15:18:54 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-10 21:00:22 +0100
commitdfed088a50298fe4a9d0eb8a9d0a2711dfc206c1 (patch)
tree08b5ad6b162a2ca15e173aa190c961a89c5340b6 /src/qml/jsruntime/qv4property_p.h
parentf67335fc340eafba04437e4b75ce9ac3edbffc54 (diff)
Fix copying of Property's
Data properties don't contain valid data in the set field if they are being stored in Objects. Thus we should never access that field unless we are dealing with accessor properties. Change-Id: I19dcbaee7ebd042ae24387f92a93571d75ca578a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4property_p.h')
-rw-r--r--src/qml/jsruntime/qv4property_p.h31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h
index aceb6022f8..4d59b6d1fe 100644
--- a/src/qml/jsruntime/qv4property_p.h
+++ b/src/qml/jsruntime/qv4property_p.h
@@ -70,18 +70,6 @@ struct Property {
attrs->resolve();
}
- static inline Property fromValue(Value v) {
- Property pd;
- pd.value = v;
- return pd;
- }
- static inline Property fromAccessor(FunctionObject *getter, FunctionObject *setter) {
- Property pd;
- pd.value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter));
- pd.set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter));
- return pd;
- }
-
static Property genericDescriptor() {
Property pd;
pd.value = Primitive::emptyValue();
@@ -95,6 +83,23 @@ struct Property {
inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.asManaged()); }
inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); }
inline void setSetter(FunctionObject *s) { set = Primitive::fromManaged(reinterpret_cast<Managed *>(s)); }
+
+ void copy(const Property &other, PropertyAttributes attrs) {
+ value = other.value;
+ if (attrs.isAccessor())
+ set = other.set;
+ }
+
+ explicit Property() { value = Encode::undefined(); set = Encode::undefined(); }
+ explicit Property(Value v) : value(v) { set = Encode::undefined(); }
+ Property(FunctionObject *getter, FunctionObject *setter) {
+ value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter));
+ set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter));
+ }
+ Property &operator=(Value v) { value = v; return *this; }
+private:
+ Property(const Property &);
+ Property &operator=(const Property &);
};
inline bool Property::isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const
@@ -140,6 +145,8 @@ inline void Property::merge(PropertyAttributes &attrs, const Property &other, Pr
}
+Q_DECLARE_TYPEINFO(QV4::Property, Q_MOVABLE_TYPE);
+
QT_END_NAMESPACE
#endif