Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.0.0 Beta 1
-
None
-
Windows
-
cbf476242608a575595651a2eb8c40588a4631a4
Description
A windows font GDI handle can be leaked in QWindowsFontEngine::alphaMapForGlyph. This is causing steady leak in our application. It is caused by an early function return in the code without cleanup.
BUG FOUND IN: qtbase/src/plugins/platforms/windows/qwindowsfontengine.cpp (line 1170)
CODE:
HFONT font = hfont; if (m_fontEngineData->clearTypeEnabled) { LOGFONT lf = m_logfont; lf.lfQuality = ANTIALIASED_QUALITY; font = CreateFontIndirect(&lf); } QImage::Format mask_format = QWindowsNativeImage::systemFormat(); mask_format = QImage::Format_RGB32; QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format); if (mask == 0) return QImage(); ...
POSSIBLE CLEANUP SOLUTION:
HFONT font = hfont; bool createdFont = false; if (m_fontEngineData->clearTypeEnabled) { LOGFONT lf = m_logfont; lf.lfQuality = ANTIALIASED_QUALITY; font = CreateFontIndirect(&lf); createdFont = true; } QImage::Format mask_format = QWindowsNativeImage::systemFormat(); mask_format = QImage::Format_RGB32; QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format); if (mask == 0){ if(createdFont){ DeleteObject(font); } return QImage(); }