diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-12-03 10:42:07 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-12-20 12:00:04 +0100 |
commit | db7b7d4161048ec481d80deaac5ff8cfa9487626 (patch) | |
tree | 752f9935485909f936c6adbcfd847cfa4763c85e /src/qml/jsruntime/qv4property_p.h | |
parent | 42aba3076dc9b6c4f8f35dd79cbf2992f7373d4f (diff) |
Return a Heap object from the getter()/setter() methods of Property
We actually need to put the returned value into a ScopedFunctionObject
before calling it, as the Property could get deleted during the call
leading to a dangling pointer. With a GC that moves objects this will
become even more important.
Change-Id: I43bece6f80eb3501c1291065846e230a59ae8aed
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.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4property_p.h b/src/qml/jsruntime/qv4property_p.h index ef58b4c0f8..50d3c0e351 100644 --- a/src/qml/jsruntime/qv4property_p.h +++ b/src/qml/jsruntime/qv4property_p.h @@ -71,10 +71,10 @@ struct Property { inline bool isSubset(const PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs) const; inline void merge(PropertyAttributes &attrs, const Property &other, PropertyAttributes otherAttrs); - inline FunctionObject *getter() const { return reinterpret_cast<FunctionObject *>(value.asManaged()); } - inline FunctionObject *setter() const { return reinterpret_cast<FunctionObject *>(set.asManaged()); } + inline Heap::FunctionObject *getter() const { return value.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(value.heapObject()) : 0; } + inline Heap::FunctionObject *setter() const { return set.isManaged() ? reinterpret_cast<Heap::FunctionObject *>(set.heapObject()) : 0; } inline void setGetter(FunctionObject *g) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(g)); } - inline void setSetter(FunctionObject *s) { set = Primitive::fromManaged(reinterpret_cast<Managed *>(s)); } + inline void setSetter(FunctionObject *s) { set = s ? Primitive::fromManaged(reinterpret_cast<Managed *>(s)) : Value::fromHeapObject(0); } void copy(const Property &other, PropertyAttributes attrs) { value = other.value; @@ -82,8 +82,8 @@ struct Property { set = other.set; } - explicit Property() { value = Encode::undefined(); set = Encode::undefined(); } - explicit Property(Value v) : value(v) { set = Encode::undefined(); } + explicit Property() { value = Encode::undefined(); set = Value::fromHeapObject(0); } + explicit Property(Value v) : value(v) { set = Value::fromHeapObject(0); } Property(FunctionObject *getter, FunctionObject *setter) { value = Primitive::fromManaged(reinterpret_cast<Managed *>(getter)); set = Primitive::fromManaged(reinterpret_cast<Managed *>(setter)); @@ -111,9 +111,9 @@ inline bool Property::isSubset(const PropertyAttributes &attrs, const Property & if (attrs.type() == PropertyAttributes::Data && !value.sameValue(other.value)) return false; if (attrs.type() == PropertyAttributes::Accessor) { - if (value.asManaged() != other.value.asManaged()) + if (value.heapObject() != other.value.heapObject()) return false; - if (set.asManaged() != other.set.asManaged()) + if (set.heapObject() != other.set.heapObject()) return false; } return true; |