Fix GDI leaks in fontengine

GDI objects that are created need to be deleted once no longer needed,
instead of just released.

Task-number: QTBUG-27812
Task-number: QTBUG-27825
Change-Id: I53b04b54cea9e2aaa8fc72365c215f516c5682e6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Miikka Heikkinen 2012-11-05 13:00:34 +02:00 committed by The Qt Project
parent 7e81938628
commit cbf4762426
2 changed files with 6 additions and 3 deletions

View File

@ -533,7 +533,7 @@ QWindowsFontEngineData::QWindowsFontEngineData()
QWindowsFontEngineData::~QWindowsFontEngineData()
{
if (hdc)
ReleaseDC(0, hdc);
DeleteDC(hdc);
#if !defined(QT_NO_DIRECTWRITE)
if (directWriteGdiInterop)
directWriteGdiInterop->Release();

View File

@ -1110,7 +1110,7 @@ QWindowsNativeImage *QWindowsFontEngine::drawGDIGlyph(HFONT font, glyph_t glyph,
SetGraphicsMode(hdc, GM_COMPATIBLE);
SelectObject(hdc, old_font);
ReleaseDC(0, hdc);
DeleteDC(hdc);
}
#else // else wince
unsigned int options = 0;
@ -1166,8 +1166,11 @@ QImage QWindowsFontEngine::alphaMapForGlyph(glyph_t glyph, const QTransform &xfo
mask_format = QImage::Format_RGB32;
QWindowsNativeImage *mask = drawGDIGlyph(font, glyph, 0, xform, mask_format);
if (mask == 0)
if (mask == 0) {
if (m_fontEngineData->clearTypeEnabled)
DeleteObject(font);
return QImage();
}
QImage indexed(mask->width(), mask->height(), QImage::Format_Indexed8);