Skip to content

Commit c2dca4c

Browse files
author
Rhys Weatherley
committed
Fix memory leak of QGLGlyphCoord objects in the OpenGL1 paint engine
Task-number: QTBUG-6936 Reviewed-by: Julian de Bhal
1 parent e84ec05 commit c2dca4c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/opengl/qpaintengine_opengl.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4707,6 +4707,12 @@ typedef QHash<QFontEngine*, QGLGlyphHash*> QGLFontGlyphHash;
47074707
typedef QHash<quint64, QGLFontTexture*> QGLFontTexHash;
47084708
typedef QHash<const QGLContext*, QGLFontGlyphHash*> QGLContextHash;
47094709

4710+
static inline void qt_delete_glyph_hash(QGLGlyphHash *hash)
4711+
{
4712+
qDeleteAll(*hash);
4713+
delete hash;
4714+
}
4715+
47104716
class QGLGlyphCache : public QObject
47114717
{
47124718
Q_OBJECT
@@ -4747,7 +4753,7 @@ void QGLGlyphCache::fontEngineDestroyed(QObject *o)
47474753
if (font_cache->find(fe) != font_cache->end()) {
47484754
ctx = keys.at(i);
47494755
QGLGlyphHash *cache = font_cache->take(fe);
4750-
delete cache;
4756+
qt_delete_glyph_hash(cache);
47514757
break;
47524758
}
47534759
}
@@ -4784,7 +4790,7 @@ void QGLGlyphCache::cleanupContext(const QGLContext *ctx)
47844790
QList<QFontEngine *> keys = font_cache->keys();
47854791
for (int i=0; i < keys.size(); ++i) {
47864792
QFontEngine *fe = keys.at(i);
4787-
delete font_cache->take(fe);
4793+
qt_delete_glyph_hash(font_cache->take(fe));
47884794
quint64 font_key = (reinterpret_cast<quint64>(ctx) << 32) | reinterpret_cast<quint64>(fe);
47894795
QGLFontTexture *font_tex = qt_font_textures.take(font_key);
47904796
if (font_tex) {
@@ -4825,7 +4831,9 @@ void QGLGlyphCache::cleanCache()
48254831
QList<const QGLContext *> keys = qt_context_cache.keys();
48264832
for (int i=0; i < keys.size(); ++i) {
48274833
QGLFontGlyphHash *font_cache = qt_context_cache.value(keys.at(i));
4828-
qDeleteAll(*font_cache);
4834+
QGLFontGlyphHash::Iterator it = font_cache->begin();
4835+
for (; it != font_cache->end(); ++it)
4836+
qt_delete_glyph_hash(it.value());
48294837
font_cache->clear();
48304838
}
48314839
qDeleteAll(qt_context_cache);

0 commit comments

Comments
 (0)