From: Miikka Heikkinen Date: Mon, 5 Nov 2012 11:00:34 +0000 (+0200) Subject: Fix GDI leaks in fontengine X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbf476242608a575595651a2eb8c40588a4631a4;p=profile%2Fivi%2Fqtbase.git 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 --- diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 323cff1..76fe5f1 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -533,7 +533,7 @@ QWindowsFontEngineData::QWindowsFontEngineData() QWindowsFontEngineData::~QWindowsFontEngineData() { if (hdc) - ReleaseDC(0, hdc); + DeleteDC(hdc); #if !defined(QT_NO_DIRECTWRITE) if (directWriteGdiInterop) directWriteGdiInterop->Release(); diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index 0e592ae..578a0cd 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -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);