aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraybuffer_p.h
diff options
context:
space:
mode:
authorValery Kotov <kotov.valery@gmail.com>2015-03-25 20:17:08 +0200
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2015-04-15 09:27:59 +0000
commit175772b3de48f7b24d6ab28255eed28e7cb53eb1 (patch)
treef07ff961a34f1c0db9d32a406aa70d65c493d96b /src/qml/jsruntime/qv4arraybuffer_p.h
parent171c318a2b6593479cdd78023804c90fb291708a (diff)
QML Engine: Share data for ArrayBuffer created from QByteArray.
ExecutionEngine performs shallow copy of internal data for ArrayBuffer created from QByteArray. Change-Id: I514cd9708a7fbe9a989937fac62d00b464d7362d Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com> Reviewed-by: Valery Kotov <kotov.valery@gmail.com> Reviewed-by: Pasi Keränen <pasi.keranen@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4arraybuffer_p.h')
-rw-r--r--src/qml/jsruntime/qv4arraybuffer_p.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4arraybuffer_p.h b/src/qml/jsruntime/qv4arraybuffer_p.h
index 9e19a83f1e..fe3150618d 100644
--- a/src/qml/jsruntime/qv4arraybuffer_p.h
+++ b/src/qml/jsruntime/qv4arraybuffer_p.h
@@ -48,6 +48,7 @@ struct ArrayBufferCtor : FunctionObject {
struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object {
ArrayBuffer(ExecutionEngine *e, size_t length);
+ ArrayBuffer(ExecutionEngine *e, const QByteArray& array);
~ArrayBuffer();
QTypedArrayData<char> *data;
@@ -74,15 +75,11 @@ struct Q_QML_PRIVATE_EXPORT ArrayBuffer : Object
QByteArray asByteArray() const;
uint byteLength() const { return d()->byteLength(); }
- char *data() {
- // ### detach if refcount > 1
- return d()->data->data();
- }
- const char *constData() {
- // ### detach if refcount > 1
- return d()->data->data();
- }
+ char *data() { detach(); return d()->data ? d()->data->data() : 0; }
+ const char *constData() { detach(); return d()->data ? d()->data->data() : 0; }
+private:
+ void detach();
};
struct ArrayBufferPrototype: Object