diff options
author | Ben Key <bkey1@tampabay.rr.com> | 2002-12-18 06:16:28 +0000 |
---|---|---|
committer | Ben Key <bkey1@tampabay.rr.com> | 2002-12-18 06:16:28 +0000 |
commit | 9785d95b98c184d5051775555e5af0b707a5ce9a (patch) | |
tree | 3685b3a963b97270c8512dbc8fe38140c0464212 /src/w32menu.c | |
parent | 250465030318621ed461d261e7807bf25b2f90b1 (diff) | |
download | emacs-9785d95b98c184d5051775555e5af0b707a5ce9a.tar.gz |
Revisited my earlier fix for the following entry in etc/PROBLEMS: 'Emacs built on Windows 9x/ME crashes at startup on Windows XP, or Emacs builtpart of on XP crashes at startup on Windows 9x/ME.' Fixed several Windows API errors detected by BoundsChecker
Diffstat (limited to 'src/w32menu.c')
-rw-r--r-- | src/w32menu.c | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/src/w32menu.c b/src/w32menu.c index 8139a0ad956..e573986b31c 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -130,6 +130,7 @@ typedef struct _widget_value static HMENU current_popup_menu; void syms_of_w32menu (); +void globals_of_w32menu (); typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) ( IN HMENU, @@ -1606,26 +1607,6 @@ void initialize_frame_menubar (f) FRAME_PTR f; { - HMODULE user32 = GetModuleHandle ("user32.dll"); - /* - Reinitialize the function pointers set_menu_item_info and - get_menu_item_info here. - Even though these function pointers are initialized in - syms_of_w32menu which is called from main (emacs.c), - we need to initialize them again here in order to prevent - a crash that occurs in Windows 9x (possibly only when Emacs - was built on Windows NT / 2000 / XP?) in add_menu_item. - The crash occurs when attempting to call the Win32 API - function SetMenuItemInfo through the function pointer. - It appears as if the function pointer that is obtained when - syms_of_w32menu is called from main is no longer valid - (possibly due to DLL relocation?). - To resolve this issue, I have placed calls to reinitialize - these function pointers here because this function is the - entry point for menu creation. - */ - get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); - set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); /* This function is called before the first chance to redisplay the frame. It has to be, so the frame will have the right size. */ FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); @@ -2392,11 +2373,7 @@ w32_free_menu_strings (hwnd) void syms_of_w32menu () { - /* See if Get/SetMenuItemInfo functions are available. */ - HMODULE user32 = GetModuleHandle ("user32.dll"); - get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); - set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); - + globals_of_w32menu (); staticpro (&menu_items); menu_items = Qnil; @@ -2415,3 +2392,19 @@ The enable predicate for a menu command should check this variable. */); defsubr (&Sx_popup_dialog); #endif } + +/* + globals_of_w32menu is used to initialize those global variables that + must always be initialized on startup even when the global variable + initialized is non zero (see the function main in emacs.c). + globals_of_w32menu is called from syms_of_w32menu when the global + variable initialized is 0 and directly from main when initialized + is non zero. + */ +void globals_of_w32menu () +{ + /* See if Get/SetMenuItemInfo functions are available. */ + HMODULE user32 = GetModuleHandle ("user32.dll"); + get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); + set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); +} |