1 From c2dca4c9f1eb360305de5ea520a0b322737dc600 Mon Sep 17 00:00:00 2001
2 From: Rhys Weatherley <rhys.weatherley@nokia.com>
3 Date: Mon, 21 Dec 2009 08:35:43 +1000
4 Subject: [PATCH 1175/1244] Fix memory leak of QGLGlyphCoord objects in the OpenGL1 paint engine
6 Task-number: QTBUG-6936
7 Reviewed-by: Julian de Bhal
9 src/opengl/qpaintengine_opengl.cpp | 14 +++++++++++---
10 1 files changed, 11 insertions(+), 3 deletions(-)
12 diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
13 index 4823408..9c15d56 100644
14 --- a/src/opengl/qpaintengine_opengl.cpp
15 +++ b/src/opengl/qpaintengine_opengl.cpp
16 @@ -4707,6 +4707,12 @@ typedef QHash<QFontEngine*, QGLGlyphHash*> QGLFontGlyphHash;
17 typedef QHash<quint64, QGLFontTexture*> QGLFontTexHash;
18 typedef QHash<const QGLContext*, QGLFontGlyphHash*> QGLContextHash;
20 +static inline void qt_delete_glyph_hash(QGLGlyphHash *hash)
26 class QGLGlyphCache : public QObject
29 @@ -4747,7 +4753,7 @@ void QGLGlyphCache::fontEngineDestroyed(QObject *o)
30 if (font_cache->find(fe) != font_cache->end()) {
32 QGLGlyphHash *cache = font_cache->take(fe);
34 + qt_delete_glyph_hash(cache);
38 @@ -4784,7 +4790,7 @@ void QGLGlyphCache::cleanupContext(const QGLContext *ctx)
39 QList<QFontEngine *> keys = font_cache->keys();
40 for (int i=0; i < keys.size(); ++i) {
41 QFontEngine *fe = keys.at(i);
42 - delete font_cache->take(fe);
43 + qt_delete_glyph_hash(font_cache->take(fe));
44 quint64 font_key = (reinterpret_cast<quint64>(ctx) << 32) | reinterpret_cast<quint64>(fe);
45 QGLFontTexture *font_tex = qt_font_textures.take(font_key);
47 @@ -4825,7 +4831,9 @@ void QGLGlyphCache::cleanCache()
48 QList<const QGLContext *> keys = qt_context_cache.keys();
49 for (int i=0; i < keys.size(); ++i) {
50 QGLFontGlyphHash *font_cache = qt_context_cache.value(keys.at(i));
51 - qDeleteAll(*font_cache);
52 + QGLFontGlyphHash::Iterator it = font_cache->begin();
53 + for (; it != font_cache->end(); ++it)
54 + qt_delete_glyph_hash(it.value());
57 qDeleteAll(qt_context_cache);