aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp2
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 1628cfe4da..296471692c 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -276,7 +276,7 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx)
if (scope.hasException())
return Encode::undefined();
if (instance->isArrayObject())
- instance->setArrayLengthUnchecked(len - 1);
+ instance->setArrayLength(len - 1);
else
instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1)));
return result.asReturnedValue();
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 726f8636b6..a1662b495c 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -146,6 +146,8 @@ private slots:
void threadedEngine();
void functionDeclarationsInConditionals();
+
+ void arrayPop_QTBUG_35979();
};
tst_QJSEngine::tst_QJSEngine()
@@ -2692,6 +2694,17 @@ void tst_QJSEngine::functionDeclarationsInConditionals()
QCOMPARE(result.toBool(), true);
}
+void tst_QJSEngine::arrayPop_QTBUG_35979()
+{
+ QJSEngine eng;
+ QJSValue result = eng.evaluate(""
+ "var x = [1, 2]\n"
+ "x.pop()\n"
+ "x[1] = 3\n"
+ "x.toString()\n");
+ QCOMPARE(result.toString(), QString("1,3"));
+}
+
QTEST_MAIN(tst_QJSEngine)
#include "tst_qjsengine.moc"