BUG: General Protection Fault When Accessing an HFONTLast reviewed: July 23, 1997Article ID: Q114013 |
3.10
WINDOWS
kbprg kbbuglist
The information in this article applies to:
SYMPTOMSOn rare occasions, in low memory situations or after calling the function GlobalCompact(-1), a general protection fault (GPF) may occur when calling SelectObject() to select a handle to a logical font (HFONT) into a device context. This happens when the application caches the handle to the logical font.
CAUSEPart of the internal data structure for the font resides in global memory that is allocated as GMEM_DISCARDABLE. In tight memory situations, this global memory may be discarded and GDI does not detect this situation before attempting to access the memory.
STATUSMicrosoft has confirmed this to be a bug in Windows version 3.1. This problem does not occur in Windows 95.
MORE INFORMATIONTo avoid this bug, applications should not cache font handles but instead hold onto the LOGFONT structure that contains the information for recreating the font. By holding onto the LOGFONT and calling the function CreateFontIndirect() each time a font is needed, applications should be able to safely avoid this bug. NOTE: The call to CreateFontIndirect() is not an expensive call in terms of performance. The actual mapping of logical font to physical font happens when you call SelectObject(). When you cache HFONTs, you still have to call SelectObject() each time before calling any of the Windows text APIs so this approach only requires one additional function call.
|
Additional reference words: buglist3.10 3.10 font fault error
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |