From: Simon Hausmann Date: Mon, 1 Jul 2013 03:49:26 +0000 (+0200) Subject: Fix qqmlecmascript::sequenceConversionThreads with aggressive GC X-Git-Tag: upstream/5.2.1~669^2~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=35deea613e96f9fced4fc48b1c5e59a4f7ee8e38;p=platform%2Fupstream%2Fqtdeclarative.git Fix qqmlecmascript::sequenceConversionThreads with aggressive GC During the deserialization of a sequence, make sure that when the collector runs during the filling of the array, that partially filled array is marked properly. Fixed setting of arrayDataLen in other similar places as well. Change-Id: I19926f733c7c7d1398b11b48c1c37f43e7099ead Reviewed-by: Lars Knoll --- diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 58ef5d0..c07144a 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -524,13 +524,13 @@ QV4::Value QQmlLocaleData::method_get_weekDays(QV4::SimpleCallContext *ctx) QV4::ArrayObject *result = ctx->engine->newArrayObject(); result->arrayReserve(days.size()); + result->arrayDataLen = days.size(); for (int i = 0; i < days.size(); ++i) { int day = days.at(i); if (day == 7) // JS Date days in range 0(Sunday) to 6(Saturday) day = 0; result->arrayData[i].value = QV4::Value::fromInt32(day); } - result->arrayDataLen = days.size(); result->setArrayLengthUnchecked(days.size()); return QV4::Value::fromObject(result); @@ -542,9 +542,9 @@ QV4::Value QQmlLocaleData::method_get_uiLanguages(QV4::SimpleCallContext *ctx) QStringList langs = locale.uiLanguages(); QV4::ArrayObject *result = ctx->engine->newArrayObject(); result->arrayReserve(langs.size()); + result->arrayDataLen = langs.size(); for (int i = 0; i < langs.size(); ++i) result->arrayData[i].value = QV4::Value::fromString(ctx, langs.at(i)); - result->arrayDataLen = langs.size(); result->setArrayLengthUnchecked(langs.size()); return QV4::Value::fromObject(result); diff --git a/src/qml/qml/v4/qv4jsonobject.cpp b/src/qml/qml/v4/qv4jsonobject.cpp index a330eae..782c388 100644 --- a/src/qml/qml/v4/qv4jsonobject.cpp +++ b/src/qml/qml/v4/qv4jsonobject.cpp @@ -1006,9 +1006,9 @@ QV4::Value JsonObject::fromJsonArray(ExecutionEngine *engine, const QJsonArray & int size = array.size(); ArrayObject *a = engine->newArrayObject(); a->arrayReserve(size); + a->arrayDataLen = size; for (int i = 0; i < size; i++) a->arrayData[i].value = fromJsonValue(engine, array.at(i)); - a->arrayDataLen = size; a->setArrayLengthUnchecked(size); return Value::fromObject(a); } diff --git a/src/qml/qml/v4/qv4qobjectwrapper.cpp b/src/qml/qml/v4/qv4qobjectwrapper.cpp index 92fa220..dc7b50e 100644 --- a/src/qml/qml/v4/qv4qobjectwrapper.cpp +++ b/src/qml/qml/v4/qv4qobjectwrapper.cpp @@ -1603,9 +1603,9 @@ QV4::Value CallArgument::toValue(QV8Engine *engine) QList &list = *qlistPtr; QV4::ArrayObject *array = v4->newArrayObject(); array->arrayReserve(list.count()); - for (int ii = 0; ii < list.count(); ++ii) - array->arrayData[ii].value = QV4::QObjectWrapper::wrap(v4, list.at(ii)); array->arrayDataLen = list.count(); + for (int ii = 0; ii < list.count(); ++ii) + array->arrayData[ii].value = QV4::QObjectWrapper::wrap(v4, list.at(ii)); array->setArrayLengthUnchecked(list.count()); return QV4::Value::fromObject(array); } else if (type == qMetaTypeId()) { diff --git a/src/qml/qml/v4/qv4serialize.cpp b/src/qml/qml/v4/qv4serialize.cpp index 3d0d313..f7389dc 100644 --- a/src/qml/qml/v4/qv4serialize.cpp +++ b/src/qml/qml/v4/qv4serialize.cpp @@ -370,9 +370,9 @@ QV4::Value Serialize::deserialize(const char *&data, QV8Engine *engine) int sequenceType = deserialize(data, engine).integerValue(); QV4::ArrayObject *array = v4->newArrayObject(); array->arrayReserve(seqLength); + array->arrayDataLen = seqLength; for (quint32 ii = 0; ii < seqLength; ++ii) array->arrayData[ii].value = deserialize(data, engine); - array->arrayDataLen = seqLength; array->setArrayLengthUnchecked(seqLength); QVariant seqVariant = QV4::SequencePrototype::toVariant(QV4::Value::fromObject(array), sequenceType, &succeeded); return QV4::SequencePrototype::fromVariant(v4, seqVariant, &succeeded); diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 859685a..804a6e3 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -184,9 +184,9 @@ static QV4::Value arrayFromStringList(QV8Engine *engine, const QStringList &list QV4::ArrayObject *a = e->newArrayObject(); int len = list.count(); a->arrayReserve(len); + a->arrayDataLen = len; for (int ii = 0; ii < len; ++ii) a->arrayData[ii].value = QV4::Value::fromString(e->newString(list.at(ii))); - a->arrayDataLen = len; a->setArrayLengthUnchecked(len); return QV4::Value::fromObject(a); } @@ -197,9 +197,9 @@ static QV4::Value arrayFromVariantList(QV8Engine *engine, const QVariantList &li QV4::ArrayObject *a = e->newArrayObject(); int len = list.count(); a->arrayReserve(len); + a->arrayDataLen = len; for (int ii = 0; ii < len; ++ii) a->arrayData[ii].value = engine->fromVariant(list.at(ii)); - a->arrayDataLen = len; a->setArrayLengthUnchecked(len); return QV4::Value::fromObject(a); } @@ -305,9 +305,9 @@ QV4::Value QV8Engine::fromVariant(const QVariant &variant) const QList &list = *(QList*)ptr; QV4::ArrayObject *a = m_v4Engine->newArrayObject(); a->arrayReserve(list.count()); + a->arrayDataLen = list.count(); for (int ii = 0; ii < list.count(); ++ii) a->arrayData[ii].value = QV4::QObjectWrapper::wrap(m_v4Engine, list.at(ii)); - a->arrayDataLen = list.count(); a->setArrayLengthUnchecked(list.count()); return QV4::Value::fromObject(a); } @@ -504,9 +504,9 @@ QV4::Value QV8Engine::variantListToJS(const QVariantList &lst) { QV4::ArrayObject *a = m_v4Engine->newArrayObject(); a->arrayReserve(lst.size()); + a->arrayDataLen = lst.size(); for (int i = 0; i < lst.size(); i++) a->arrayData[i].value = variantToJS(lst.at(i)); - a->arrayDataLen = lst.size(); a->setArrayLengthUnchecked(lst.size()); return QV4::Value::fromObject(a); }