mirror of
https://github.com/holub/mame
synced 2025-07-05 09:57:47 +03:00
font_windows.c: don't crash if no memory for bitmap [Peter Ferrie]
more graceful exit will occur when next malloc() fails, and condition might be temporary
This commit is contained in:
parent
490ed5ce9b
commit
9cf8308096
@ -169,6 +169,9 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT
|
|||||||
// create a DIB to render to
|
// create a DIB to render to
|
||||||
BYTE *bits;
|
BYTE *bits;
|
||||||
HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);
|
HBITMAP dib = CreateDIBSection(dummyDC, &info, DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits), NULL, 0);
|
||||||
|
|
||||||
|
if (dib)
|
||||||
|
{
|
||||||
HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);
|
HGDIOBJ oldbitmap = SelectObject(dummyDC, dib);
|
||||||
|
|
||||||
// clear the bitmap
|
// clear the bitmap
|
||||||
@ -253,6 +256,8 @@ bool osd_font_windows::get_bitmap(unicode_char chnum, bitmap_argb32 &bitmap, INT
|
|||||||
// de-select the font and release the DC
|
// de-select the font and release the DC
|
||||||
SelectObject(dummyDC, oldbitmap);
|
SelectObject(dummyDC, oldbitmap);
|
||||||
DeleteObject(dib);
|
DeleteObject(dib);
|
||||||
|
}
|
||||||
|
|
||||||
SelectObject(dummyDC, oldfont);
|
SelectObject(dummyDC, oldfont);
|
||||||
DeleteDC(dummyDC);
|
DeleteDC(dummyDC);
|
||||||
return bitmap.valid();
|
return bitmap.valid();
|
||||||
|
Loading…
Reference in New Issue
Block a user