gdiplus: font: Ensure to release resources.
This commit is contained in:
parent
d54c53a4b6
commit
4cafd76f2d
|
@ -42,6 +42,7 @@ static inline REAL get_dpi (void)
|
||||||
HDC hdc = GetDC(0);
|
HDC hdc = GetDC(0);
|
||||||
GdipCreateFromHDC (hdc, &graphics);
|
GdipCreateFromHDC (hdc, &graphics);
|
||||||
GdipGetDpiX(graphics, &dpi);
|
GdipGetDpiX(graphics, &dpi);
|
||||||
|
GdipDeleteGraphics(graphics);
|
||||||
ReleaseDC (0, hdc);
|
ReleaseDC (0, hdc);
|
||||||
|
|
||||||
return dpi;
|
return dpi;
|
||||||
|
@ -351,7 +352,7 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
|
||||||
{
|
{
|
||||||
GpFontFamily* ffamily;
|
GpFontFamily* ffamily;
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
HFONT hFont;
|
HFONT hFont, hfont_old;
|
||||||
LOGFONTW lfw;
|
LOGFONTW lfw;
|
||||||
|
|
||||||
TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
|
TRACE("%s, %p %p\n", debugstr_w(name), fontCollection, FontFamily);
|
||||||
|
@ -371,14 +372,17 @@ GpStatus WINGDIPAPI GdipCreateFontFamilyFromName(GDIPCONST WCHAR *name,
|
||||||
hdc = GetDC(0);
|
hdc = GetDC(0);
|
||||||
lstrcpynW(lfw.lfFaceName, name, sizeof(WCHAR) * LF_FACESIZE);
|
lstrcpynW(lfw.lfFaceName, name, sizeof(WCHAR) * LF_FACESIZE);
|
||||||
hFont = CreateFontIndirectW (&lfw);
|
hFont = CreateFontIndirectW (&lfw);
|
||||||
SelectObject(hdc, hFont);
|
hfont_old = SelectObject(hdc, hFont);
|
||||||
|
|
||||||
GetTextMetricsW(hdc, ffamily->tmw);
|
GetTextMetricsW(hdc, ffamily->tmw);
|
||||||
|
DeleteObject(SelectObject(hdc, hfont_old));
|
||||||
|
|
||||||
ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR));
|
ffamily->FamilyName = GdipAlloc(LF_FACESIZE * sizeof (WCHAR));
|
||||||
if (!ffamily->FamilyName)
|
if (!ffamily->FamilyName)
|
||||||
{
|
{
|
||||||
|
GdipFree(ffamily->tmw);
|
||||||
GdipFree(ffamily);
|
GdipFree(ffamily);
|
||||||
|
ReleaseDC(0, hdc);
|
||||||
return OutOfMemory;
|
return OutOfMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue