Mercurial > emacs
comparison src/w32menu.c @ 48888:f0df5f687c15
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
author | Ben Key <bkey1@tampabay.rr.com> |
---|---|
date | Wed, 18 Dec 2002 06:16:28 +0000 |
parents | 4d7b83cc03aa |
children | 08ac5c346b16 |
comparison
equal
deleted
inserted
replaced
48887:e846f8d1619c | 48888:f0df5f687c15 |
---|---|
128 #endif /* no TRUE */ | 128 #endif /* no TRUE */ |
129 | 129 |
130 static HMENU current_popup_menu; | 130 static HMENU current_popup_menu; |
131 | 131 |
132 void syms_of_w32menu (); | 132 void syms_of_w32menu (); |
133 void globals_of_w32menu (); | |
133 | 134 |
134 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) ( | 135 typedef BOOL (WINAPI * GetMenuItemInfoA_Proc) ( |
135 IN HMENU, | 136 IN HMENU, |
136 IN UINT, | 137 IN UINT, |
137 IN BOOL, | 138 IN BOOL, |
1604 | 1605 |
1605 void | 1606 void |
1606 initialize_frame_menubar (f) | 1607 initialize_frame_menubar (f) |
1607 FRAME_PTR f; | 1608 FRAME_PTR f; |
1608 { | 1609 { |
1609 HMODULE user32 = GetModuleHandle ("user32.dll"); | |
1610 /* | |
1611 Reinitialize the function pointers set_menu_item_info and | |
1612 get_menu_item_info here. | |
1613 Even though these function pointers are initialized in | |
1614 syms_of_w32menu which is called from main (emacs.c), | |
1615 we need to initialize them again here in order to prevent | |
1616 a crash that occurs in Windows 9x (possibly only when Emacs | |
1617 was built on Windows NT / 2000 / XP?) in add_menu_item. | |
1618 The crash occurs when attempting to call the Win32 API | |
1619 function SetMenuItemInfo through the function pointer. | |
1620 It appears as if the function pointer that is obtained when | |
1621 syms_of_w32menu is called from main is no longer valid | |
1622 (possibly due to DLL relocation?). | |
1623 To resolve this issue, I have placed calls to reinitialize | |
1624 these function pointers here because this function is the | |
1625 entry point for menu creation. | |
1626 */ | |
1627 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); | |
1628 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); | |
1629 /* This function is called before the first chance to redisplay | 1610 /* This function is called before the first chance to redisplay |
1630 the frame. It has to be, so the frame will have the right size. */ | 1611 the frame. It has to be, so the frame will have the right size. */ |
1631 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); | 1612 FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f)); |
1632 set_frame_menubar (f, 1, 1); | 1613 set_frame_menubar (f, 1, 1); |
1633 } | 1614 } |
2390 | 2371 |
2391 #endif /* HAVE_MENUS */ | 2372 #endif /* HAVE_MENUS */ |
2392 | 2373 |
2393 void syms_of_w32menu () | 2374 void syms_of_w32menu () |
2394 { | 2375 { |
2395 /* See if Get/SetMenuItemInfo functions are available. */ | 2376 globals_of_w32menu (); |
2396 HMODULE user32 = GetModuleHandle ("user32.dll"); | |
2397 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); | |
2398 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); | |
2399 | |
2400 staticpro (&menu_items); | 2377 staticpro (&menu_items); |
2401 menu_items = Qnil; | 2378 menu_items = Qnil; |
2402 | 2379 |
2403 current_popup_menu = NULL; | 2380 current_popup_menu = NULL; |
2404 | 2381 |
2413 defsubr (&Sx_popup_menu); | 2390 defsubr (&Sx_popup_menu); |
2414 #ifdef HAVE_MENUS | 2391 #ifdef HAVE_MENUS |
2415 defsubr (&Sx_popup_dialog); | 2392 defsubr (&Sx_popup_dialog); |
2416 #endif | 2393 #endif |
2417 } | 2394 } |
2395 | |
2396 /* | |
2397 globals_of_w32menu is used to initialize those global variables that | |
2398 must always be initialized on startup even when the global variable | |
2399 initialized is non zero (see the function main in emacs.c). | |
2400 globals_of_w32menu is called from syms_of_w32menu when the global | |
2401 variable initialized is 0 and directly from main when initialized | |
2402 is non zero. | |
2403 */ | |
2404 void globals_of_w32menu () | |
2405 { | |
2406 /* See if Get/SetMenuItemInfo functions are available. */ | |
2407 HMODULE user32 = GetModuleHandle ("user32.dll"); | |
2408 get_menu_item_info = (GetMenuItemInfoA_Proc) GetProcAddress (user32, "GetMenuItemInfoA"); | |
2409 set_menu_item_info = (SetMenuItemInfoA_Proc) GetProcAddress (user32, "SetMenuItemInfoA"); | |
2410 } |