diff options
author | Kent Hansen <khansen@trolltech.com> | 2009-07-13 09:18:22 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-07-13 09:25:57 (GMT) |
commit | a267b590d17d1e7088acf44a8ba7e307f898ccb1 (patch) | |
tree | 11b7a48ef6251b6184f4a38303cf99a8b5fb2cdc /src/script/bridge | |
parent | 2859da9f22517099ce5d193398b7cc417a9c54d7 (diff) | |
download | Qt-a267b590d17d1e7088acf44a8ba7e307f898ccb1.zip Qt-a267b590d17d1e7088acf44a8ba7e307f898ccb1.tar.gz Qt-a267b590d17d1e7088acf44a8ba7e307f898ccb1.tar.bz2 |
add GC marking guards
Caller is responsible for calling marked() before mark(),
otherwise you might get infinite recursion.
Diffstat (limited to 'src/script/bridge')
-rw-r--r-- | src/script/bridge/qscriptobject.cpp | 6 | ||||
-rw-r--r-- | src/script/bridge/qscriptqobject.cpp | 21 |
2 files changed, 19 insertions, 8 deletions
diff --git a/src/script/bridge/qscriptobject.cpp b/src/script/bridge/qscriptobject.cpp index b657af7..5cf415a 100644 --- a/src/script/bridge/qscriptobject.cpp +++ b/src/script/bridge/qscriptobject.cpp @@ -113,7 +113,8 @@ void QScriptObject::getPropertyNames(JSC::ExecState* exec, JSC::PropertyNameArra void QScriptObject::mark() { - if (d && d->data) + Q_ASSERT(!marked()); + if (d && d->data && !d->data.marked()) d->data.mark(); if (!d || !d->delegate) { JSC::JSObject::mark(); @@ -203,7 +204,8 @@ void QScriptObjectDelegate::getPropertyNames(QScriptObject* object, JSC::ExecSta void QScriptObjectDelegate::mark(QScriptObject* object) { - object->JSC::JSObject::mark(); + if (!object->marked()) + object->JSC::JSObject::mark(); } JSC::CallType QScriptObjectDelegate::getCallData(QScriptObject* object, JSC::CallData& data) diff --git a/src/script/bridge/qscriptqobject.cpp b/src/script/bridge/qscriptqobject.cpp index a17daea..ff58102 100644 --- a/src/script/bridge/qscriptqobject.cpp +++ b/src/script/bridge/qscriptqobject.cpp @@ -82,9 +82,9 @@ struct QObjectConnection } #endif } - if (receiver) + if (receiver && !receiver.marked()) receiver.mark(); - if (slot) + if (slot && !slot.marked()) slot.mark(); } }; @@ -234,7 +234,13 @@ JSC::CallType QtFunction::getCallData(JSC::CallData &callData) void QtFunction::mark() { - data->object.mark(); + Q_ASSERT(!marked()); + if (data->object && !data->object.marked()) { + // FIXME: Causes infinite recursion because the object will mark this function, + // which will again mark the object, and so on. Need an "is marking" flag. +// data->object.mark(); + } + JSC::InternalFunction::mark(); } QScriptObject *QtFunction::wrapperObject() const @@ -1498,10 +1504,13 @@ void QObjectDelegate::getPropertyNames(QScriptObject *object, JSC::ExecState *ex void QObjectDelegate::mark(QScriptObject *object) { QHash<QByteArray, JSC::JSValue>::const_iterator it; - for (it = data->cachedMembers.constBegin(); it != data->cachedMembers.constEnd(); ++it) - JSC::asObject(it.value())->mark(); + for (it = data->cachedMembers.constBegin(); it != data->cachedMembers.constEnd(); ++it) { + JSC::JSValue val = it.value(); + if (val && !val.marked()) + val.mark(); + } - object->JSC::JSObject::mark(); + QScriptObjectDelegate::mark(object); } static JSC::JSValue JSC_HOST_CALL qobjectProtoFuncFindChild(JSC::ExecState *exec, JSC::JSObject*, |