aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4sequenceobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-08-27 15:09:12 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-09-01 19:25:21 +0200
commit09883c77882534e2ccb262c748ab0d9d7cfdc2f0 (patch)
treedb85353b55ca04b38327a9f02b7d3fba6f2ff92a /src/qml/jsruntime/qv4sequenceobject.cpp
parentcc86fb0095b39193c15d1d1992524ec311edc256 (diff)
QtQml: Consistently check isReadOnly in QV4::Sequence
We want generally want to throw an exception. Except in virtualMetaCall, since that would lead to cascading exceptions. There, just return 0 to notify the caller about the metaCall failure. Change-Id: Ie3970d01a5b433100f9722a2f12843abfe8d512a Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 7a357babe7..cfef4baf8b 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -373,8 +373,12 @@ bool Sequence::virtualDeleteProperty(Managed *that, PropertyKey id)
Heap::Sequence *p = static_cast<Sequence *>(that)->d();
- if (p->isReadOnly())
+ if (p->isReadOnly()) {
+ p->internalClass->engine->throwTypeError(
+ QLatin1String("Cannot delete from a readonly container"));
return false;
+ }
+
if (p->isReference() && !p->loadReference())
return false;
@@ -444,6 +448,9 @@ int Sequence::virtualMetacall(Object *object, QMetaObject::Call call, int index,
break;
}
case QMetaObject::WriteProperty: {
+ if (p->isReadOnly())
+ return 0;
+
void *storagePointer = p->storagePointer();
const QMetaSequence metaSequence = p->metaSequence();
if (index < 0 || index >= metaSequence.size(storagePointer))
@@ -550,6 +557,8 @@ ReturnedValue SequencePrototype::method_shift(
return ArrayPrototype::method_shift(b, thisObject, argv, argc);
Heap::Sequence *p = s->d();
+ if (p->isReadOnly())
+ THROW_TYPE_ERROR();
if (p->isReference() && !p->loadReference())
RETURN_UNDEFINED();