Fix the dataloss problem when shutting down Windows (part of bug #5525).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@31114 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-08-18 11:49:00 +00:00
parent 5c1ebb63fc
commit a91c42b7db
5 changed files with 46 additions and 1 deletions

View File

@ -65,6 +65,10 @@ using ::boost::scoped_ptr;
namespace lyx {
// Keep the linker happy on Windows
void emergencyCleanup()
{}
namespace support {
string itoa(unsigned int i)

View File

@ -33,6 +33,9 @@
using namespace std;
namespace lyx {
void emergencyCleanup();
namespace support {
namespace os {
@ -122,15 +125,29 @@ string convert_path_list(string const & p, PathStyle const & target)
return subst(p, '\\', '/');
}
BOOL terminate_handler(DWORD event)
{
if (event == CTRL_CLOSE_EVENT
|| event == CTRL_LOGOFF_EVENT
|| event == CTRL_SHUTDOWN_EVENT) {
lyx::emergencyCleanup();
return TRUE;
}
return FALSE;
}
} // namespace anon
void init(int, char *[])
{
// Make sure that the TEMP variable is set
// and sync the Windows environment.
setenv("TEMP", "/tmp", false);
cygwin_internal(CW_SYNC_WINENV);
// Catch shutdown events.
SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, TRUE);
}

View File

@ -71,6 +71,9 @@
using namespace std;
namespace lyx {
void emergencyCleanup();
namespace support {
namespace os {
@ -80,6 +83,17 @@ bool windows_style_tex_paths_ = true;
string cygdrive = "/cygdrive";
BOOL terminate_handler(DWORD event)
{
if (event == CTRL_CLOSE_EVENT
|| event == CTRL_LOGOFF_EVENT
|| event == CTRL_SHUTDOWN_EVENT) {
lyx::emergencyCleanup();
return TRUE;
}
return FALSE;
}
} // namespace anon
void init(int /* argc */, char * argv[])
@ -161,6 +175,9 @@ void init(int /* argc */, char * argv[])
if ((retVal == ERROR_SUCCESS) && (bufSize <= MAX_PATH))
cygdrive = rtrim(string(buf), "/");
}
// Catch shutdown events.
SetConsoleCtrlHandler((PHANDLER_ROUTINE)terminate_handler, TRUE);
}

View File

@ -41,6 +41,11 @@ using namespace lyx::support::os;
namespace lyx {
// Keep the linker happy on Windows
void emergencyCleanup()
{}
string const trim(string const & a, char const * p)
{
// LASSERT(p, /**/);

View File

@ -179,6 +179,8 @@ What's new
- Enable document margin settings and hyperref settings in the
article (beamer) class.
- Fix data loss when shutting down Windows (part of bug 5525).
* USER INTERFACE