aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4persistent.cpp
diff options
context:
space:
mode:
authorJian Liang <jianliang79@gmail.com>2015-11-18 22:30:26 +0800
committerjian liang <jianliang79@gmail.com>2015-12-18 15:52:43 +0000
commit839d2d3e2368bc8e107d22203b0611c852f54319 (patch)
tree6ea5f2b5bb5fca87e37872352f24c85649589ac2 /src/qml/jsruntime/qv4persistent.cpp
parent4b018848f7a7055976895de8a4b8208b58a36fac (diff)
Fix QtSharedPointer::ExternalRefCountData object leaks
Call destroyObject() for every QV4::Heap::QObectWrapper object in heap in QV4::MemoryManager::sweep() to make sure the QPointer object contained in QV4::Heap::QObjectWrapper is properly destructed. We also keep track of QObjectWrapper in QV4::Heap::ModelObject to make sure we destory them in QV4::MemoryManager::sweep() Change-Id: I3b3e96cfc300c2e21ab691762879ac2970afa90c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/jsruntime/qv4persistent.cpp')
-rw-r--r--src/qml/jsruntime/qv4persistent.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/qml/jsruntime/qv4persistent.cpp b/src/qml/jsruntime/qv4persistent.cpp
index 4a0f84b685..032ad0d00a 100644
--- a/src/qml/jsruntime/qv4persistent.cpp
+++ b/src/qml/jsruntime/qv4persistent.cpp
@@ -34,6 +34,7 @@
#include "qv4persistent_p.h"
#include <private/qv4mm_p.h>
#include "qv4object_p.h"
+#include "qv4qobjectwrapper_p.h"
#include "PageAllocation.h"
using namespace QV4;
@@ -204,6 +205,12 @@ void PersistentValueStorage::free(Value *v)
Page *p = getPage(v);
+ // Keep track of QObjectWrapper to release its resources later in MemoryManager::sweep()
+ if (p->header.engine) {
+ if (QObjectWrapper *qobjectWrapper = v->as<QObjectWrapper>())
+ p->header.engine->memoryManager->m_pendingDestroyedObjectWrappers.push_back(qobjectWrapper->d());
+ }
+
v->setTag(QV4::Value::Empty_Type);
v->setInt_32(p->header.freeList);
p->header.freeList = v - p->values;