comparison src/w32fns.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 cf6379011f93
children 24de3cf96fb0
comparison
equal deleted inserted replaced
48887:e846f8d1619c 48888:f0df5f687c15
52 #include <shellapi.h> 52 #include <shellapi.h>
53 #include <ctype.h> 53 #include <ctype.h>
54 54
55 #include <dlgs.h> 55 #include <dlgs.h>
56 #define FILE_NAME_TEXT_FIELD edt1 56 #define FILE_NAME_TEXT_FIELD edt1
57
58 void syms_of_w32fns ();
59 void globals_of_w32fns ();
57 60
58 extern void free_frame_menubar (); 61 extern void free_frame_menubar ();
59 extern void x_compute_fringe_widths P_ ((struct frame *, int)); 62 extern void x_compute_fringe_widths P_ ((struct frame *, int));
60 extern double atof (); 63 extern double atof ();
61 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object)); 64 extern int w32_console_toggle_lock_key P_ ((int, Lisp_Object));
4932 or exposed, so should recheck visibility of all frames. */ 4935 or exposed, so should recheck visibility of all frames. */
4933 my_post_msg (&wmsg, hwnd, msg, wParam, lParam); 4936 my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
4934 goto dflt; 4937 goto dflt;
4935 4938
4936 case WM_SETFOCUS: 4939 case WM_SETFOCUS:
4937 /*
4938 Reinitialize the function pointer track_mouse_event_fn here.
4939 This is required even though it is initialized in syms_of_w32fns
4940 which is called in main (emacs.c).
4941 Reinitialize the function pointer track_mouse_event_fn here.
4942 Even though this function pointer is initialized in
4943 syms_of_w32fns which is called from main (emacs.c),
4944 we need to initialize it again here in order to prevent
4945 a crash that occurs in Windows 9x (possibly only when Emacs
4946 was built on Windows NT / 2000 / XP?) when handling the
4947 WM_MOUSEMOVE message.
4948 The crash occurs when attempting to call the Win32 API
4949 function TrackMouseEvent through the function pointer.
4950 It appears as if the function pointer that is obtained when
4951 syms_of_w32fns is called from main is no longer valid
4952 (possibly due to DLL relocation?).
4953 To resolve this issue, I have placed a call to reinitialize
4954 this function pointer here because this message gets received
4955 when the Emacs window gains focus.
4956 */
4957 track_mouse_event_fn =
4958 (TrackMouseEvent_Proc) GetProcAddress (
4959 GetModuleHandle ("user32.dll"),
4960 "TrackMouseEvent");
4961 dpyinfo->faked_key = 0; 4940 dpyinfo->faked_key = 0;
4962 reset_modifiers (); 4941 reset_modifiers ();
4963 register_hot_keys (hwnd); 4942 register_hot_keys (hwnd);
4964 goto command; 4943 goto command;
4965 case WM_KILLFOCUS: 4944 case WM_KILLFOCUS:
14904 ***********************************************************************/ 14883 ***********************************************************************/
14905 14884
14906 void 14885 void
14907 syms_of_w32fns () 14886 syms_of_w32fns ()
14908 { 14887 {
14909 HMODULE user32_lib = GetModuleHandle ("user32.dll"); 14888 globals_of_w32fns ();
14910 14889 /* This is zero if not using MS-Windows. */
14911 /* This is zero if not using MS-Windows. */
14912 w32_in_use = 0; 14890 w32_in_use = 0;
14913
14914 /* TrackMouseEvent not available in all versions of Windows, so must load
14915 it dynamically. Do it once, here, instead of every time it is used. */
14916 track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent");
14917 track_mouse_window = NULL; 14891 track_mouse_window = NULL;
14918 14892
14919 w32_visible_system_caret_hwnd = NULL; 14893 w32_visible_system_caret_hwnd = NULL;
14920 14894
14921 Qauto_raise = intern ("auto-raise"); 14895 Qauto_raise = intern ("auto-raise");
15494 staticpro (&last_show_tip_args); 15468 staticpro (&last_show_tip_args);
15495 15469
15496 defsubr (&Sx_file_dialog); 15470 defsubr (&Sx_file_dialog);
15497 } 15471 }
15498 15472
15499 15473
15474 /*
15475 globals_of_w32fns is used to initialize those global variables that
15476 must always be initialized on startup even when the global variable
15477 initialized is non zero (see the function main in emacs.c).
15478 globals_of_w32fns is called from syms_of_w32fns when the global
15479 variable initialized is 0 and directly from main when initialized
15480 is non zero.
15481 */
15482 void globals_of_w32fns ()
15483 {
15484 HMODULE user32_lib = GetModuleHandle ("user32.dll");
15485 /*
15486 TrackMouseEvent not available in all versions of Windows, so must load
15487 it dynamically. Do it once, here, instead of every time it is used.
15488 */
15489 track_mouse_event_fn = (TrackMouseEvent_Proc) GetProcAddress (user32_lib, "TrackMouseEvent");
15490 }
15491
15492
15500 void 15493 void
15501 init_xfns () 15494 init_xfns ()
15502 { 15495 {
15503 image_types = NULL; 15496 image_types = NULL;
15504 Vimage_types = Qnil; 15497 Vimage_types = Qnil;