diff options
Diffstat (limited to 'src/qml/memory/qv4mm.cpp')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 18676ec8e6..fe94a11082 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -47,8 +47,6 @@ #include "StdLibExtras.h" #include <QTime> -#include <QVector> -#include <QVector> #include <QMap> #include <iostream> @@ -443,6 +441,21 @@ void MemoryManager::sweep(bool lastSweep) (*it) = Primitive::undefinedValue(); } + // Now it is time to free QV4::QObjectWrapper Value, we must check the Value's tag to make sure its object has been destroyed + const int pendingCount = m_pendingFreedObjectWrapperValue.count(); + if (pendingCount) { + QVector<Value *> remainingWeakQObjectWrappers; + remainingWeakQObjectWrappers.reserve(pendingCount); + for (int i = 0; i < pendingCount; ++i) { + Value *v = m_pendingFreedObjectWrapperValue.at(i); + if (v->tag() == Value::Undefined_Type) + PersistentValueStorage::free(v); + else + remainingWeakQObjectWrappers.append(v); + } + m_pendingFreedObjectWrapperValue = remainingWeakQObjectWrappers; + } + if (MultiplyWrappedQObjectMap *multiplyWrappedQObjects = engine->m_multiplyWrappedQObjects) { for (MultiplyWrappedQObjectMap::Iterator it = multiplyWrappedQObjects->begin(); it != multiplyWrappedQObjects->end();) { if (!it.value().isNullOrUndefined()) |