(svn r18184) -Codechange: add crash screenshot for win32

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
glx 15 years ago
parent 68400db749
commit 2535b1afcf

@ -44,6 +44,8 @@ public:
char crashlog_filename[MAX_PATH]; char crashlog_filename[MAX_PATH];
/** Buffer for the filename of the crash dump */ /** Buffer for the filename of the crash dump */
char crashdump_filename[MAX_PATH]; char crashdump_filename[MAX_PATH];
/** Buffer for the filename of the crash screenshot */
char screenshot_filename[MAX_PATH];
/** /**
* A crash log is always generated when it's generated. * A crash log is always generated when it's generated.
@ -55,6 +57,7 @@ public:
this->crashlog[0] = '\0'; this->crashlog[0] = '\0';
this->crashlog_filename[0] = '\0'; this->crashlog_filename[0] = '\0';
this->crashdump_filename[0] = '\0'; this->crashdump_filename[0] = '\0';
this->screenshot_filename[0] = '\0';
} }
/** /**
@ -380,6 +383,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
log->FillCrashLog(log->crashlog, lastof(log->crashlog)); log->FillCrashLog(log->crashlog, lastof(log->crashlog));
log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename)); log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename));
log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename)); log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename));
log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename));
/* Close any possible log files */ /* Close any possible log files */
CloseConsoleLogIfActive(); CloseConsoleLogIfActive();
@ -430,10 +434,10 @@ static const TCHAR _crash_desc[] =
_T("This will greatly help debugging. The correct place to do this is http://bugs.openttd.org. ") _T("This will greatly help debugging. The correct place to do this is http://bugs.openttd.org. ")
_T("The information contained in the report is displayed below.\n") _T("The information contained in the report is displayed below.\n")
_T("Press \"Emergency save\" to attempt saving the game. Generated file(s):\n") _T("Press \"Emergency save\" to attempt saving the game. Generated file(s):\n")
_T("'%s%s%s'"); _T("%s");
static const TCHAR _save_succeeded[] = static const TCHAR _save_succeeded[] =
_T("Emergency save succeeded. Its location is '%s'.\n") _T("Emergency save succeeded.\nIts location is '%s'.\n")
_T("Be aware that critical parts of the internal game state may have become ") _T("Be aware that critical parts of the internal game state may have become ")
_T("corrupted. The saved game is not guaranteed to work."); _T("corrupted. The saved game is not guaranteed to work.");
@ -481,11 +485,21 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA
*p = '\0'; *p = '\0';
/* Add path to crash.log and crash.dmp (if any) to the crash window text */ /* Add path to crash.log and crash.dmp (if any) to the crash window text */
size_t len = _tcslen(_crash_desc) + _tcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + _tcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 4; size_t len = _tcslen(_crash_desc) + 2;
len += _tcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + 2;
len += _tcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 2;
len += _tcslen(OTTD2FS(CrashLogWindows::current->screenshot_filename)) + 1;
TCHAR *text = AllocaM(TCHAR, len); TCHAR *text = AllocaM(TCHAR, len);
TCHAR *dump = _tcsdup(OTTD2FS(CrashLogWindows::current->crashdump_filename)); _sntprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename));
_sntprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename), dump[0] != _T('\0') ? _T("'\n'") : _T(""), dump); if (OTTD2FS(CrashLogWindows::current->crashdump_filename)[0] != _T('\0')) {
free(dump); _tcscat(text, _T("\n"));
_tcscat(text, OTTD2FS(CrashLogWindows::current->crashdump_filename));
}
if (OTTD2FS(CrashLogWindows::current->screenshot_filename)[0] != _T('\0')) {
_tcscat(text, _T("\n"));
_tcscat(text, OTTD2FS(CrashLogWindows::current->screenshot_filename));
}
SetDlgItemText(wnd, 10, text); SetDlgItemText(wnd, 10, text);
SetDlgItemText(wnd, 11, MB_TO_WIDE_BUFFER(dos_nl, crash_msgW, lengthof(crash_msgW))); SetDlgItemText(wnd, 11, MB_TO_WIDE_BUFFER(dos_nl, crash_msgW, lengthof(crash_msgW)));

@ -46,17 +46,17 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT
// Dialog // Dialog
// //
100 DIALOG DISCARDABLE 0, 0, 305, 91 100 DIALOG DISCARDABLE 0, 0, 305, 99
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Fatal Application Failure" CAPTION "Fatal Application Failure"
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
PUSHBUTTON "&Close",12,7,72,50,14 PUSHBUTTON "&Close",12,7,80,50,14
PUSHBUTTON "&Emergency save",13,155,72,68,14 PUSHBUTTON "&Emergency save",13,155,80,68,14
PUSHBUTTON "",15,243,72,55,14 PUSHBUTTON "",15,243,80,55,14
EDITTEXT 11,7,93,291,118,ES_MULTILINE | ES_READONLY | WS_VSCROLL | EDITTEXT 11,7,101,291,118,ES_MULTILINE | ES_READONLY | WS_VSCROLL |
WS_HSCROLL | NOT WS_TABSTOP WS_HSCROLL | NOT WS_TABSTOP
LTEXT "",10,36,7,262,57 LTEXT "",10,36,7,262,65
ICON 100,IDC_STATIC,9,9,20,20 ICON 100,IDC_STATIC,9,9,20,20
END END

Loading…
Cancel
Save