aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory/qv4mm.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-08-26 17:50:44 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2018-08-28 21:45:48 +0000
commit94f0d86b5d4c52a6af4843d05d47e7dcf2d1acaa (patch)
tree60e7d8615999d854e365c4caf1fc003ab83540c9 /src/qml/memory/qv4mm.cpp
parent464b878b973710077b2b92b1682d6f38c83554dd (diff)
Add support for WeakSet
Change-Id: I5cee2bf0c6a45ad2c14b52e1a4fc5ef015e01042 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/memory/qv4mm.cpp')
-rw-r--r--src/qml/memory/qv4mm.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 065204b5d3..b9e6327ea2 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -62,6 +62,7 @@
#include "qv4alloca_p.h"
#include "qv4profiling_p.h"
#include "qv4mapobject_p.h"
+#include "qv4setobject_p.h"
//#define MM_STATS
@@ -989,6 +990,17 @@ void MemoryManager::sweep(bool lastSweep, ClassDestroyStatsCallback classCountPt
map = map->nextWeakMap;
}
+ Heap::SetObject *set = weakSets;
+ Heap::SetObject **lastSet = &weakSets;
+ while (set) {
+ if (set->isMarked()) {
+ set->removeUnmarkedKeys();
+ *lastSet = set;
+ lastSet = &set->nextWeakSet;
+ }
+ set = set->nextWeakSet;
+ }
+
// onDestruction handlers may have accessed other QObject wrappers and reset their value, so ensure
// that they are all set to undefined.
for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) {
@@ -1198,6 +1210,12 @@ void MemoryManager::registerWeakMap(Heap::MapObject *map)
weakMaps = map;
}
+void MemoryManager::registerWeakSet(Heap::SetObject *set)
+{
+ set->nextWeakSet = weakSets;
+ weakSets = set;
+}
+
MemoryManager::~MemoryManager()
{
delete m_persistentValues;