aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arraydata.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-04-27 08:47:35 +0200
committerLiang Qi <liang.qi@qt.io>2016-04-27 08:47:35 +0200
commitda374438be8f34f746f359aa39ae6c59fd1c4854 (patch)
tree2f3e2a2b93b39dfb825339c98580f23e824fad0e /src/qml/jsruntime/qv4arraydata.cpp
parent1be53f4e143d417d60cd1f9a292193dab59b5b20 (diff)
parent2e6f7f362e62c3285e7d395aca607502c8e8160e (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/quick/items/qquickimagebase.cpp src/imports/layouts/plugin.cpp Change-Id: I5f48474df4034a1347ec74795c85d369a55b6b21
Diffstat (limited to 'src/qml/jsruntime/qv4arraydata.cpp')
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index 728ee38e76..8f002c7b65 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -287,7 +287,13 @@ void SimpleArrayData::push_front(Object *o, const Value *values, uint n)
Q_ASSERT(o->d()->arrayData->type == Heap::ArrayData::Simple);
dd = o->d()->arrayData.cast<Heap::SimpleArrayData>();
}
- dd->offset = (dd->offset - n) % dd->alloc;
+ if (n <= dd->offset) {
+ dd->offset -= n; // there is enough space left in front
+ } else {
+ // we need to wrap around, so:
+ dd->offset = dd->alloc - // start at the back, but subtract:
+ (n - dd->offset); // the number of items we can put in the free space at the start of the allocated array
+ }
dd->len += n;
for (uint i = 0; i < n; ++i)
dd->data(i) = values[i].asReturnedValue();