From: Lars Knoll Date: Thu, 13 Jun 2013 16:27:06 +0000 (+0200) Subject: fix deleteProperty on a string objects X-Git-Tag: upstream/5.2.1~669^2~220 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1e3d28b8ba33d1c73d9276517463016336e7d268;p=platform%2Fupstream%2Fqtdeclarative.git fix deleteProperty on a string objects For array indices that are part of the string, deleteProperty should fail. Change-Id: Ib253ddd5b3b04d2edc9b744a9407451c2a9778fd Reviewed-by: Simon Hausmann --- diff --git a/src/qml/qml/v4/qv4stringobject.cpp b/src/qml/qml/v4/qv4stringobject.cpp index 7e309ca..0dbd052 100644 --- a/src/qml/qml/v4/qv4stringobject.cpp +++ b/src/qml/qml/v4/qv4stringobject.cpp @@ -99,6 +99,20 @@ Property *StringObject::getIndex(uint index) const return &tmpProperty; } +bool StringObject::deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index) +{ + StringObject *o = m->asStringObject(); + if (!o) + ctx->throwTypeError(); + + if (index < o->value.stringValue()->toQString().length()) { + if (ctx->strictMode) + ctx->throwTypeError(); + return false; + } + return true; +} + Property *StringObject::advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs) { StringObject *s = static_cast(m); diff --git a/src/qml/qml/v4/qv4stringobject_p.h b/src/qml/qml/v4/qv4stringobject_p.h index a5a64c1..a4786d8 100644 --- a/src/qml/qml/v4/qv4stringobject_p.h +++ b/src/qml/qml/v4/qv4stringobject_p.h @@ -50,15 +50,18 @@ QT_BEGIN_NAMESPACE namespace QV4 { struct StringObject: Object { + Q_MANAGED + Value value; mutable Property tmpProperty; StringObject(ExecutionEngine *engine, const Value &value); Property *getIndex(uint index) const; + static bool deleteIndexedProperty(Managed *m, ExecutionContext *ctx, uint index); + protected: static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs); - static const ManagedVTable static_vtbl; static void markObjects(Managed *that); }; diff --git a/src/qml/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp index ffb4a0b..5e0c087 100644 --- a/src/qml/qml/v8/qjsvalue.cpp +++ b/src/qml/qml/v8/qjsvalue.cpp @@ -919,7 +919,7 @@ bool QJSValue::deleteProperty(const QString &name) return false; ExecutionEngine *engine = d->engine(); - String *s = engine->newIdentifier(name); + String *s = engine->newString(name); return o->deleteProperty(engine->current, s); }