diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2009-11-30 13:15:50 (GMT) |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2009-11-30 14:53:12 (GMT) |
commit | 132eccca92a90e4d67ba8b5a4052384a2b2cfdf9 (patch) | |
tree | cff488b3d812dcb077771aafd51be979797c63fa /src/script/api | |
parent | 634a2c456732903b116a73e674f1391f77d530d8 (diff) | |
download | Qt-132eccca92a90e4d67ba8b5a4052384a2b2cfdf9.zip Qt-132eccca92a90e4d67ba8b5a4052384a2b2cfdf9.tar.gz Qt-132eccca92a90e4d67ba8b5a4052384a2b2cfdf9.tar.bz2 |
Fix garbage collection issue with script-owned objects with connections
This reinstates the pre-4.6 behavior: A script-owned C++ object
that's not referenced anymore should be garbage collected, even
if it has connections. In order to achieve this, the "weak"
reference to the C++ object's wrapper must be invalidated.
Task-number: QTBUG-6366
Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/script/api')
-rw-r--r-- | src/script/api/qscriptengine.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index dc0e0d0..b6aa872 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -1101,16 +1101,6 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) } } -#ifndef QT_NO_QOBJECT - { - QHash<QObject*, QScript::QObjectData*>::const_iterator it; - for (it = m_qobjectData.constBegin(); it != m_qobjectData.constEnd(); ++it) { - QScript::QObjectData *qdata = it.value(); - qdata->mark(markStack); - } - } -#endif - { QHash<int, QScriptTypeInfo*>::const_iterator it; for (it = m_typeInfos.constBegin(); it != m_typeInfos.constEnd(); ++it) { @@ -1134,6 +1124,17 @@ void QScriptEnginePrivate::mark(JSC::MarkStack& markStack) context = context->parentContext(); } } + +#ifndef QT_NO_QOBJECT + markStack.drain(); // make sure everything is marked before marking qobject data + { + QHash<QObject*, QScript::QObjectData*>::const_iterator it; + for (it = m_qobjectData.constBegin(); it != m_qobjectData.constEnd(); ++it) { + QScript::QObjectData *qdata = it.value(); + qdata->mark(markStack); + } + } +#endif } bool QScriptEnginePrivate::isCollecting() const |