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