diff options
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4value_p.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 9eee34aff2..6d5cff4ecc 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -372,16 +372,22 @@ public: } Q_ALWAYS_INLINE String *stringValue() const { + if (!isString()) + return nullptr; return m() ? reinterpret_cast<String*>(const_cast<Value *>(this)) : 0; } Q_ALWAYS_INLINE Object *objectValue() const { + if (!isObject()) + return nullptr; return m() ? reinterpret_cast<Object*>(const_cast<Value *>(this)) : 0; } Q_ALWAYS_INLINE Managed *managed() const { + if (!isManaged()) + return nullptr; return m() ? reinterpret_cast<Managed*>(const_cast<Value *>(this)) : 0; } Q_ALWAYS_INLINE Heap::Base *heapObject() const { - return m(); + return isManaged() ? m() : nullptr; } static inline Value fromHeapObject(Heap::Base *m) @@ -431,7 +437,10 @@ public: } template <typename T> T *as() { - return const_cast<T *>(const_cast<const Value *>(this)->as<T>()); + if (isManaged()) + return const_cast<T *>(const_cast<const Value *>(this)->as<T>()); + else + return nullptr; } template<typename T> inline T *cast() { @@ -471,11 +480,8 @@ public: template<typename T> Value &operator=(const Scoped<T> &t); - Value &operator=(const Value &v) { - _val = v._val; - return *this; - } }; +V4_ASSERT_IS_TRIVIAL(Value) inline bool Value::isString() const { |