aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4scopedvalue_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-23 15:52:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-26 09:05:16 +0200
commit12fd2ccd3fa2dc0133b5a3fb89f9fdf5cf721232 (patch)
tree880acb9c7c0d8289185b6aebe4339f439c707a0e /src/qml/jsruntime/qv4scopedvalue_p.h
parent2e4f66caa8a5f9e887dbdb4e3f2ae5c9be9a7005 (diff)
Fix Persistent/WeakValue API
Don't use unprotected Values in the API anymore. Change-Id: I8851628227fca374de24701bc8ee0908b5ae3923 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4scopedvalue_p.h')
-rw-r--r--src/qml/jsruntime/qv4scopedvalue_p.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h
index 09851af091..f11a982b65 100644
--- a/src/qml/jsruntime/qv4scopedvalue_p.h
+++ b/src/qml/jsruntime/qv4scopedvalue_p.h
@@ -439,6 +439,10 @@ struct Referenced {
Referenced(const Scoped<T> &v)
: ptr(v.ptr) {}
Referenced(Safe<T> &v) { ptr = &v; }
+ Referenced(SafeValue &v) {
+ ptr = value_cast<T>(v) ? &v : 0;
+ }
+
Referenced &operator=(const Referenced &o)
{ *ptr = *o.ptr; return *this; }
Referenced &operator=(T *t)
@@ -465,7 +469,7 @@ struct Referenced {
T *getPointer() const {
return static_cast<T *>(ptr->managed());
}
- ReturnedValue asReturnedValue() const { return ptr->val; }
+ ReturnedValue asReturnedValue() const { return ptr ? ptr->val : Value::undefinedValue().asReturnedValue(); }
static Referenced null() { return Referenced(Null); }
bool isNull() const { return !ptr; }
@@ -643,7 +647,7 @@ PersistentValue::PersistentValue(Returned<T> *obj)
}
template<typename T>
-inline PersistentValue::PersistentValue(const Scoped<T> &obj)
+inline PersistentValue::PersistentValue(const Referenced<T> obj)
: d(new PersistentValuePrivate(*obj.ptr))
{
}
@@ -655,7 +659,7 @@ inline PersistentValue &PersistentValue::operator=(Returned<T> *obj)
}
template<typename T>
-inline PersistentValue &PersistentValue::operator=(const Scoped<T> &obj)
+inline PersistentValue &PersistentValue::operator=(const Referenced<T> obj)
{
return operator=(*obj.ptr);
}