diff options
Diffstat (limited to 'src/qml/memory/qv4mm.cpp')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 5181bf912b..053dfb856c 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -41,8 +41,6 @@ #include "StdLibExtras.h" #include <QTime> -#include <QVector> -#include <QVector> #include <QMap> #include <iostream> @@ -437,6 +435,15 @@ void MemoryManager::sweep(bool lastSweep) (*it) = Primitive::undefinedValue(); } + // Some QV4::QObjectWrapper objects will be removed from PersistentValueStorage in WeakValue::~WeakValue() + // before MemoryManager::sweep() is being called, in this case we will never have a chance to call detroyObject() + // on those QV4::QObjectWrapper objects. Here we call detroyObject() for each pending destroyed Heap::QObjectWrapper + // object on the heap to make sure that we can release all the resources held by them + for (QVector<Heap::QObjectWrapper *>::const_iterator it = m_pendingDestroyedObjectWrappers.constBegin(); + it != m_pendingDestroyedObjectWrappers.constEnd(); ++it) + QObjectWrapper::destroyObject(*it, lastSweep); + m_pendingDestroyedObjectWrappers.clear(); + if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) { for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) { if (!it.value().isNullOrUndefined()) |