aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4value_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-23 12:06:25 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-23 10:15:51 +0000
commit98528ae780deecc831c115379d8aa90fa9450e44 (patch)
tree60f499fb448fc44daba42484b710989eabc5d15e /src/qml/jsruntime/qv4value_p.h
parentda9a715a52894501ae7d9292db9b33a237cce4e0 (diff)
Fix some remaining issues with detaching of array buffers
Make sure we check for detached buffers after all other calls that could execute code have happened. To do that convert the values to numbers before calling the write() methods of the specific typed array. Change-Id: I091e41400f740dfc1d0826657e285443c9336c40 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4value_p.h')
-rw-r--r--src/qml/jsruntime/qv4value_p.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index 6a6df3eb6d..e4be6b99dd 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -408,6 +408,7 @@ public:
}
static bool toBooleanImpl(Value val);
double toInteger() const;
+ inline ReturnedValue convertedToNumber() const;
inline double toNumber() const;
static double toNumberImpl(Value v);
double toNumberImpl() const { return toNumberImpl(*this); }
@@ -554,6 +555,15 @@ inline double Value::toNumber() const
return toNumberImpl();
}
+inline ReturnedValue Value::convertedToNumber() const
+{
+ if (isInteger() || isDouble())
+ return asReturnedValue();
+ Value v;
+ v.setDouble(toNumberImpl());
+ return v.asReturnedValue();
+}
+
inline
ReturnedValue Heap::Base::asReturnedValue() const
{