From 4cd2f0bb2ff262bafb09eae23db919714858e4a2 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Wed, 14 Mar 2012 15:28:27 +1000 Subject: Fix memory leak with the shared distance field glyph cache. A new glyph node instance registers its owner element with its glyph cache which in the case of the shared distance field glyph cache connects a signal from the cache to a slot on the owner, changing the text creates a new node but destroying the old node didn't remove the connection causing them to accumulate over time. In the glyph node; unregister the owner element from the cache on destruction, and in the cache only connect an owner element the first time it is registered and keep a reference count so the items can be disconnected when registrations from all nodes have been cancelled. Change-Id: Ibf32a146e146dbbf4e0556d1bd756465bd8e45ba Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h') diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h index 4a91b4473a..19844bbda4 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache_p.h @@ -44,6 +44,7 @@ #include #include +#include QT_BEGIN_HEADER @@ -105,8 +106,19 @@ private: QPoint position; }; + struct Owner + { + Owner() : ref(0) {} + Owner(const Owner &o) : item(o.item), ref(o.ref) {} + Owner &operator =(const Owner &o) { item = o.item; ref = o.ref; return *this; } + + QQmlGuard item; + int ref; + }; + QHash m_pendingReadyGlyphs; QHash m_bufferForGlyph; + QHash m_registeredOwners; }; QT_END_NAMESPACE -- cgit v1.2.3