From bc8d34080100ff68f5f4c34260afaba757d4d2c7 Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Wed, 20 Jul 2011 23:37:00 -0500 Subject: [PATCH] [Win32/CrashHandlerChild] Crashlog and log now open in the player's default text editor. Also, the Show Log button works again, including for people using Portable.ini. --- Docs/Changelog_sm5.txt | 6 +++ src/archutils/Win32/CrashHandlerChild.cpp | 50 ++++++++--------------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt index ce445d891e..d16673b0c6 100644 --- a/Docs/Changelog_sm5.txt +++ b/Docs/Changelog_sm5.txt @@ -8,6 +8,12 @@ ________________________________________________________________________________ StepMania 5.0 ????????? | 20110??? -------------------------------------------------------------------------------- +2011/07/20 +---------- +* [Win32/CrashHandlerChild] Crashlog and log now open in the player's default + text editor. Also, the Show Log button works again, including for people using + Portable.ini. [AJ] + 2011/07/19 ---------- * [LoadingWindow] Added the ability for themes to have custom splash banners. diff --git a/src/archutils/Win32/CrashHandlerChild.cpp b/src/archutils/Win32/CrashHandlerChild.cpp index 03b2b9ef07..7e377017df 100644 --- a/src/archutils/Win32/CrashHandlerChild.cpp +++ b/src/archutils/Win32/CrashHandlerChild.cpp @@ -8,6 +8,7 @@ #include "archutils/Win32/ddk/dbghelp.h" #include #include +#include #include "arch/ArchHooks/ArchHooks.h" #include "archutils/Win32/WindowsResources.h" @@ -17,6 +18,7 @@ #include "archutils/Win32/RestartProgram.h" #include "archutils/Win32/CrashHandlerNetworking.h" #include "archutils/Win32/WindowsDialogBox.h" +#include "archutils/Win32/SpecialDirs.h" #include "ProductInfo.h" #include "RageUtil.h" #include "XmlFile.h" @@ -80,7 +82,6 @@ namespace VDDebugInfo pctx->sRawBlock = sBufOut; } - const unsigned char *src = (const unsigned char *) pctx->sRawBlock.data(); pctx->pRVAHeap = NULL; @@ -252,7 +253,6 @@ bool ReadFromParent( int fd, void *p, int size ) return true; } - // General symbol lookup; uses VDDebugInfo for detailed information within the // process, and DbgHelp for simpler information about loaded DLLs. namespace SymbolLookup @@ -356,7 +356,6 @@ namespace SymbolLookup return; } - RString sName = CrashChildGetModuleBaseName( (HMODULE)meminfo.AllocationBase ); DWORD64 disp; @@ -444,7 +443,7 @@ static void MakeCrashReport( const CompleteCrashData &Data, RString &sOut ) // Dump thread stacks static char buf[1024*32]; sOut += ssprintf( "%s\n", join("\n", Data.m_asCheckpoints).c_str() ); - + sOut += ReportCallStack( Data.m_CrashInfo.m_BacktracePointers ); sOut += ssprintf( "\n" ); @@ -491,33 +490,6 @@ static void DoSave( const RString &sReport ) SetFileAttributes( sName, FILE_ATTRIBUTE_READONLY ); } -void ViewWithNotepad(const char *str) -{ - char buf[256] = ""; - strcat( buf, "notepad.exe " ); - strcat( buf, str ); - - RString cwd = SpliceProgramPath( "" ); - - PROCESS_INFORMATION pi; - STARTUPINFO si; - ZeroMemory( &si, sizeof(si) ); - - CreateProcess( - NULL, // pointer to name of executable module - buf, // pointer to command line string - NULL, // process security attributes - NULL, // thread security attributes - false, // handle inheritance flag - 0, // creation flags - NULL, // pointer to new environment block - cwd, // pointer to current directory name - &si, // pointer to STARTUPINFO - &pi // pointer to PROCESS_INFORMATION - ); -} - - bool ReadCrashDataFromParent( int iFD, CompleteCrashData &Data ) { _setmode( _fileno(stdin), O_BINARY ); @@ -723,10 +695,22 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam ) // EndDialog(hDlg, TRUE); // don't always exit on ENTER return TRUE; case IDC_VIEW_LOG: - ViewWithNotepad("../log.txt"); + { + RString sLogPath; + FILE *pFile = fopen( SpliceProgramPath("../Portable.ini"), "r" ); + if(pFile != NULL) + { + sLogPath = SpliceProgramPath("../Logs/log.txt"); + fclose( pFile ); + } + else + sLogPath = SpecialDirs::GetAppDataDir() + PRODUCT_ID +"/Logs/log.txt"; + + ShellExecute( NULL, "open", sLogPath, "", "", SW_SHOWNORMAL ); + } break; case IDC_CRASH_SAVE: - ViewWithNotepad("../crashinfo.txt"); + ShellExecute( NULL, "open", SpliceProgramPath("../crashinfo.txt"), "", "", SW_SHOWNORMAL ); return TRUE; case IDC_BUTTON_RESTART: Win32RestartProgram();