From d046de0ddb7a8d8762821915d3973a1bea9d499c Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 4 Aug 2018 10:39:09 +0200 Subject: Setup the prototype correctly when subclassing error objects Change-Id: I5e394ef8d4d6d87bedb26070d51660e3ebe3ab1b Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4errorobject_p.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4errorobject_p.h') 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 - static Heap::Object *create(ExecutionEngine *e, const Value &message); + static Heap::Object *create(ExecutionEngine *e, const Value &message, const Value *newTarget); template static Heap::Object *create(ExecutionEngine *e, const QString &message); template @@ -333,10 +333,11 @@ inline SyntaxErrorObject *ErrorObject::asSyntaxError() template -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 ic(scope, e->internalClasses(klass)->changePrototype(T::defaultPrototype(e)->d())); + ScopedObject proto(scope, static_cast(newTarget)->get(scope.engine->id_prototype())); + Scoped ic(scope, e->internalClasses(klass)->changePrototype(proto->d())); return e->memoryManager->allocObject(ic->d(), message); } template -- cgit v1.2.3