diff options
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass.cpp | 10 | ||||
-rw-r--r-- | src/script/bridge/qscriptdeclarativeclass_p.h | 3 | ||||
-rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 12 |
3 files changed, 19 insertions, 6 deletions
diff --git a/src/script/bridge/qscriptdeclarativeclass.cpp b/src/script/bridge/qscriptdeclarativeclass.cpp index 0df9a49..ce2fc23 100644 --- a/src/script/bridge/qscriptdeclarativeclass.cpp +++ b/src/script/bridge/qscriptdeclarativeclass.cpp @@ -90,6 +90,11 @@ QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, const QString &value new (this) JSC::JSValue(JSC::jsString(QScriptEnginePrivate::frameForContext(ctxt), value)); } +QScriptDeclarativeClass::Value::Value(QScriptContext *ctxt, const QScriptValue &value) +{ + new (this) JSC::JSValue(QScriptEnginePrivate::get(ctxt->engine())->scriptValueToJSCValue(value)); +} + QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, int value) { new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->currentFrame, value); @@ -120,12 +125,11 @@ QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, const QString &value) new (this) JSC::JSValue(JSC::jsString(QScriptEnginePrivate::get(eng)->currentFrame, value)); } -QScriptDeclarativeClass::Value::Value(const QScriptValue &value) +QScriptDeclarativeClass::Value::Value(QScriptEngine *eng, const QScriptValue &value) { - new (this) JSC::JSValue(QScriptValuePrivate::get(&value)->engine->scriptValueToJSCValue(value)); + new (this) JSC::JSValue(QScriptEnginePrivate::get(eng)->scriptValueToJSCValue(value)); } - QScriptDeclarativeClass::Value::~Value() { ((JSC::JSValue *)(this))->~JSValue(); diff --git a/src/script/bridge/qscriptdeclarativeclass_p.h b/src/script/bridge/qscriptdeclarativeclass_p.h index 6050971..357d1d5 100644 --- a/src/script/bridge/qscriptdeclarativeclass_p.h +++ b/src/script/bridge/qscriptdeclarativeclass_p.h @@ -52,7 +52,6 @@ public: public: Value(); Value(const Value &); - Value(const QScriptValue &); Value(QScriptContext *, int); Value(QScriptContext *, uint); @@ -60,12 +59,14 @@ public: Value(QScriptContext *, double); Value(QScriptContext *, float); Value(QScriptContext *, const QString &); + Value(QScriptContext *, const QScriptValue &); Value(QScriptEngine *, int); Value(QScriptEngine *, uint); Value(QScriptEngine *, bool); Value(QScriptEngine *, double); Value(QScriptEngine *, float); Value(QScriptEngine *, const QString &); + Value(QScriptEngine *, const QScriptValue &); ~Value(); QScriptValue toScriptValue(QScriptEngine *) const; diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index fb0dddb..db312bc 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -978,7 +978,8 @@ JSC::JSValue QtFunction::execute(JSC::ExecState *exec, JSC::JSValue thisValue, QScriptObjectDelegate *delegate = scriptObject->delegate(); Q_ASSERT(delegate && (delegate->type() == QScriptObjectDelegate::QtObject)); QObject *qobj = static_cast<QScript::QObjectDelegate*>(delegate)->value(); - Q_ASSERT_X(qobj != 0, "QtFunction::call", "handle the case when QObject has been deleted"); + if (!qobj) + return JSC::throwError(exec, JSC::GeneralError, QString::fromLatin1("cannot call function of deleted QObject")); QScriptEnginePrivate *engine = scriptEngineFromExec(exec); const QMetaObject *meta = qobj->metaObject(); @@ -2219,7 +2220,14 @@ void QObjectConnectionManager::execute(int slotIndex, void **argv) JSC::call(exec, slot, callType, callData, thisObject, jscArgs); if (exec->hadException()) { - engine->emitSignalHandlerException(); + if (slot.inherits(&QtFunction::info) && !static_cast<QtFunction*>(JSC::asObject(slot))->qobject()) { + // The function threw an error because the target QObject has been deleted. + // The connections list is stale; remove the signal handler and ignore the exception. + removeSignalHandler(sender(), signalIndex, receiver, slot); + exec->clearException(); + } else { + engine->emitSignalHandlerException(); + } } } |