From 7c505f06d418e8faf7a00cf66019975a8d5a73e3 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Mon, 10 Mar 2008 06:28:21 +0000 Subject: [PATCH] Improved Aegisub's exception handling and crash log generation. Originally committed to SVN as r2008. --- aegilib/src/formats/format_ass.cpp | 6 ++- aegisub/main.cpp | 67 +++++++++++++++++++++--------- aegisub/main.h | 3 +- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/aegilib/src/formats/format_ass.cpp b/aegilib/src/formats/format_ass.cpp index fe00154b2..ff3605b54 100644 --- a/aegilib/src/formats/format_ass.cpp +++ b/aegilib/src/formats/format_ass.cpp @@ -109,8 +109,7 @@ void FormatHandlerASS::Load(wxInputStream &file,const String encoding) // Create and insert line SectionEntry *entry = MakeEntry(cur,curGroup,version); - //if (!entry) throw Exception(Exception::Parse_Error); - section->AddEntry(entry); + if (entry) section->AddEntry(entry); } // Debug @@ -172,6 +171,9 @@ SectionEntry *FormatHandlerASS::MakeEntry(String data,String group,int version) // Script info else if (group == _T("Script Info")) { + // Discard comments + if (data.Left(1) == _T(";")) return NULL; + // TODO } diff --git a/aegisub/main.cpp b/aegisub/main.cpp index abe021fdf..1fa11ac04 100644 --- a/aegisub/main.cpp +++ b/aegisub/main.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include "main.h" #include "frame_main.h" @@ -283,7 +284,7 @@ void AegisubApp::OnFatalException() { // Stack walk #if wxUSE_STACKWALKER == 1 - StackWalker walker; + StackWalker walker(_T("Fatal exception")); walker.WalkFromException(); #endif @@ -297,25 +298,35 @@ void AegisubApp::OnFatalException() { // Stack walker #if wxUSE_STACKWALKER == 1 void StackWalker::OnStackFrame(const wxStackFrame &frame) { - wxString dst = wxString::Format(_T("%03i - 0x%08X: "),frame.GetLevel(),frame.GetAddress()) + frame.GetName() + _T(" on ") + frame.GetFileName() + wxString::Format(_T(":%i"),frame.GetLine()); - char temp[2048]; + wxString dst = wxString::Format(_T("%03i - 0x%08X: "),frame.GetLevel(),frame.GetAddress()) + frame.GetName(); + if (frame.HasSourceLocation()) dst += _T(" on ") + frame.GetFileName() + wxString::Format(_T(":%i"),frame.GetLine()); if (file.is_open()) { - strcpy(temp,dst.mb_str()); - file << temp << std::endl; + file << dst.mb_str() << std::endl; } else wxLogMessage(dst); } -StackWalker::StackWalker() { +StackWalker::StackWalker(wxString cause) { file.open(wxString(StandardPaths::DecodePath(_T("?user/crashlog.txt"))).mb_str(),std::ios::out | std::ios::app); if (file.is_open()) { - file << std::endl << "Begining stack dump:\n"; + wxDateTime time = wxDateTime::Now(); + wxString timeStr = _T("---") + time.FormatISODate() + _T(" ") + time.FormatISOTime() + _T("------------------"); + formatLen = timeStr.Length(); + file << std::endl << timeStr.mb_str(wxConvLocal); + file << "\nVER - " << GetAegisubLongVersionString().mb_str(wxConvUTF8); + file << "\nFTL - Begining stack dump for \"" << cause.mb_str(wxConvUTF8) <<"\":\n"; } } StackWalker::~StackWalker() { if (file.is_open()) { - file << "End of stack dump.\n\n"; + char dashes[1024]; + int i = 0; + for (i=0;i