To: vim-dev@vim.org Subject: patch 5.5.031 (extra) Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.031 (extra) Problem: Win32 GUI: When exiting Windows, gvim will leave swap files behind and will be killed ungracefully. (Krishna) Solution: Catch the WM_QUERYENDSESSION and WM_ENDSESSION messages and try to exit gracefully. Allow the user to cancel the shutdown if there is a changed buffer. Files: src/gui_w32.c *** ../vim-5.5.30/src/gui_w32.c Sun Oct 17 20:13:49 1999 --- src/gui_w32.c Sun Oct 17 20:05:00 1999 *************** *** 621,627 **** } /* ! * Get a message when the the window is being destroyed. */ static void _OnDestroy( --- 621,627 ---- } /* ! * Get a message when the window is being destroyed. */ static void _OnDestroy( *************** *** 631,636 **** --- 631,648 ---- _OnClose(hwnd); } + /* + * Got a message when the system will go down. + */ + static void + _OnEndSession(void) + { + ml_close_notmod(); /* close all not-modified buffers */ + ml_sync_all(FALSE, FALSE); /* preserve all swap files */ + ml_close_all(FALSE); /* close all memfiles, without deleting */ + getout(1); /* exit Vim properly */ + } + static void _OnDropFiles( HWND hwnd, *************** *** 1650,1655 **** --- 1662,1676 ---- HANDLE_MSG(hwnd, WM_WINDOWPOSCHANGING, _OnWindowPosChanging); HANDLE_MSG(hwnd, WM_ACTIVATEAPP, _OnActivateApp); + case WM_QUERYENDSESSION: /* System wants to go down. */ + gui_window_closed(); /* Will exit when no changed buffers. */ + return FALSE; /* Do NOT allow system to go down. */ + + case WM_ENDSESSION: + if (wParam) /* system only really goes down when wParam is TRUE */ + _OnEndSession(); + break; + case WM_SYSCHAR: /* * if 'winaltkeys' is "no", or it's "menu" and it's not a menu *** ../vim-5.5.30/src/version.c Tue Oct 19 20:48:30 1999 --- src/version.c Sun Oct 24 19:22:29 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 31, -- DENNIS: Oh, very nice. King, eh! I expect you've got a palace and fine clothes and courtiers and plenty of food. And how d'you get that? By exploiting the workers! By hanging on to outdated imperialist dogma which perpetuates the social and economic differences in our society! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /