mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Fix the dataloss problem when shutting down Windows (part of bug #5525).
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31006 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4e082c886d
commit
945dad51bf
19
src/LyX.cpp
19
src/LyX.cpp
@ -71,6 +71,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace lyx::support;
|
||||
@ -650,6 +653,18 @@ static void error_handler(int err_sig)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
BOOL terminate_handler(DWORD event)
|
||||
{
|
||||
if (event == CTRL_CLOSE_EVENT
|
||||
|| event == CTRL_LOGOFF_EVENT
|
||||
|| event == CTRL_SHUTDOWN_EVENT)
|
||||
raise(SIGTERM);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -671,6 +686,10 @@ bool LyX::init()
|
||||
signal(SIGINT, error_handler);
|
||||
signal(SIGTERM, error_handler);
|
||||
// SIGPIPE can be safely ignored.
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
// On Windows we have also to catch logging off or closing the console.
|
||||
SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, TRUE);
|
||||
#endif
|
||||
|
||||
lyxrc.tempdir_path = package().temp_dir().absFilename();
|
||||
lyxrc.document_path = package().document_dir().absFilename();
|
||||
|
Loading…
Reference in New Issue
Block a user