aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4errorobject_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-04 10:39:09 +0200
committerLars Knoll <lars.knoll@qt.io>2018-08-06 10:00:45 +0000
commitd046de0ddb7a8d8762821915d3973a1bea9d499c (patch)
tree3e75616f9cb1e4bf9cbb5fdaa337223365e01dd5 /src/qml/jsruntime/qv4errorobject_p.h
parent15ef80f1d92eb3a88dc135b4e6347f57a5982f9c (diff)
Setup the prototype correctly when subclassing error objects
Change-Id: I5e394ef8d4d6d87bedb26070d51660e3ebe3ab1b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4errorobject_p.h')
-rw-r--r--src/qml/jsruntime/qv4errorobject_p.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h
index fd042ca8f0..bce7e4abad 100644
--- a/src/qml/jsruntime/qv4errorobject_p.h
+++ b/src/qml/jsruntime/qv4errorobject_p.h
@@ -165,7 +165,7 @@ struct ErrorObject: Object {
V4_NEEDS_DESTROY
template <typename T>
- static Heap::Object *create(ExecutionEngine *e, const Value &message);
+ static Heap::Object *create(ExecutionEngine *e, const Value &message, const Value *newTarget);
template <typename T>
static Heap::Object *create(ExecutionEngine *e, const QString &message);
template <typename T>
@@ -333,10 +333,11 @@ inline SyntaxErrorObject *ErrorObject::asSyntaxError()
template <typename T>
-Heap::Object *ErrorObject::create(ExecutionEngine *e, const Value &message) {
+Heap::Object *ErrorObject::create(ExecutionEngine *e, const Value &message, const Value *newTarget) {
EngineBase::InternalClassType klass = message.isUndefined() ? EngineBase::Class_ErrorObject : EngineBase::Class_ErrorObjectWithMessage;
Scope scope(e);
- Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d()));
+ ScopedObject proto(scope, static_cast<const Object *>(newTarget)->get(scope.engine->id_prototype()));
+ Scoped<InternalClass> ic(scope, e->internalClasses(klass)->changePrototype(proto->d()));
return e->memoryManager->allocObject<T>(ic->d(), message);
}
template <typename T>