diff --git a/aegisub/src/dialog_options.cpp b/aegisub/src/dialog_options.cpp index 2f934fc4c..a334df92c 100644 --- a/aegisub/src/dialog_options.cpp +++ b/aegisub/src/dialog_options.cpp @@ -194,14 +194,6 @@ DialogOptions::DialogOptions(wxWindow *parent) browse = new BrowseButton(filePage,-1,_T(""),BROWSE_FOLDER); browse->Bind(edit); fileSizer4->Add(browse,0,wxEXPAND); - - fileSizer4->Add(new wxStaticText(filePage,-1,_("Crash recovery path:")),0,wxRIGHT | wxALIGN_CENTRE_VERTICAL,5); - edit = new wxTextCtrl(filePage,-1); - Bind(edit,_T("Auto recovery path")); - fileSizer4->Add(edit,1,wxEXPAND); - browse = new BrowseButton(filePage,-1,_T(""),BROWSE_FOLDER); - browse->Bind(edit); - fileSizer4->Add(browse,0,wxEXPAND); fileSizer4->AddGrowableCol(1,1); // Third static box diff --git a/aegisub/src/main.cpp b/aegisub/src/main.cpp index 1e67c4185..8a5385dec 100644 --- a/aegisub/src/main.cpp +++ b/aegisub/src/main.cpp @@ -282,40 +282,36 @@ int AegisubApp::OnExit() { /// Message displayed when an exception has occurred. const static wxString exception_message = _("Oops, Aegisub has crashed!\n\nAn attempt has been made to save a copy of your file to:\n\n%s\n\nAegisub will now close."); -/// @brief Unhandled exception -/// +/// @brief Called during an unhandled exception void AegisubApp::OnUnhandledException() { - // Attempt to recover file - wxFileName origfile(AssFile::top->filename); - wxString path = Options.AsText(_T("Auto recovery path")); - if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/")); - wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/")); - path += _T("/"); - dstpath.Assign(path); - if (!dstpath.DirExists()) wxMkdir(path); - wxString filename = path + origfile.GetName() + _T(".RECOVER.ass"); + // Current filename if any. + wxFileName file(AssFile::top->filename); + if (!file.HasName()) file.SetName(_T("untitled")); + + // Set path and create if it doesn't exist. + file.SetPath(StandardPaths::DecodePath(_T("?user/recovered"))); + if (!file.DirExists()) file.Mkdir(); + + // Save file + wxString filename = wxString::Format("%s/%s_%s.ass", file.GetPath(), wxDateTime::Now().Format("%Y-%m-%d-%H%M%S"), file.GetName()); AssFile::top->Save(filename,false,false); - // Inform user of crash + // Inform user of crash. wxMessageBox(wxString::Format(exception_message, filename.c_str()), _("Program error"), wxOK | wxICON_ERROR, NULL); } - - -/// @brief Fatal exception -/// +/// @brief Called during a fatal exception. void AegisubApp::OnFatalException() { - // Attempt to recover file - wxFileName origfile(AssFile::top->filename); - wxString path = Options.AsText(_T("Auto recovery path")); - if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/")); - wxFileName dstpath(path); - if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/")); - path += _T("/"); - dstpath.Assign(path); - if (!dstpath.DirExists()) wxMkdir(path); - wxString filename = path + origfile.GetName() + _T(".RECOVER.ass"); + // Current filename if any. + wxFileName file(AssFile::top->filename); + if (!file.HasName()) file.SetName(_T("untitled")); + + // Set path and create if it doesn't exist. + file.SetPath(StandardPaths::DecodePath(_T("?user/recovered"))); + if (!file.DirExists()) file.Mkdir(); + + // Save file + wxString filename = wxString::Format("%s/%s_%s.ass", file.GetPath(), wxDateTime::Now().Format("%Y-%m-%d-%H%M%S"), file.GetName()); AssFile::top->Save(filename,false,false); #if wxUSE_STACKWALKER == 1 @@ -323,18 +319,17 @@ void AegisubApp::OnFatalException() { StackWalker walker(_T("Fatal exception")); walker.WalkFromException(); #endif + // Inform user of crash - wxMessageBox(wxString::Format(exception_message, filename.c_str()), _("Program error"), wxOK | wxICON_ERROR, NULL); + wxMessageBox(wxString::Format(exception_message, filename.c_str()), _("Program error"), wxOK | wxICON_ERROR | wxSTAY_ON_TOP, NULL); } #endif -//////////////// -// Stack walker -#if wxUSE_STACKWALKER == 1 +#ifdef wxUSE_STACKWALKER -/// @brief DOCME -/// @param frame +/// @brief Callback to format a single frame +/// @param frame frame to parse. /// void StackWalker::OnStackFrame(const wxStackFrame &frame) { wxString dst = wxString::Format(_T("%03i - 0x%08X: "),frame.GetLevel(),frame.GetAddress()) + frame.GetName(); @@ -346,8 +341,8 @@ void StackWalker::OnStackFrame(const wxStackFrame &frame) { } -/// @brief DOCME -/// @param cause +/// @brief Called at the start of walking the stack. +/// @param cause cause of the crash. /// StackWalker::StackWalker(wxString cause) { file.open(wxString(StandardPaths::DecodePath(_T("?user/crashlog.txt"))).mb_str(),std::ios::out | std::ios::app); @@ -362,8 +357,7 @@ StackWalker::StackWalker(wxString cause) { } -/// @brief DOCME -/// +/// @brief Called at the end of walking the stack. StackWalker::~StackWalker() { if (file.is_open()) { char dashes[1024]; diff --git a/aegisub/src/options.cpp b/aegisub/src/options.cpp index 70049a11b..b7864f6f2 100644 --- a/aegisub/src/options.cpp +++ b/aegisub/src/options.cpp @@ -116,7 +116,6 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) { SetText(_T("Auto save path"),_T("?user/autosave")); SetBool(_T("Auto backup"),true); SetText(_T("Auto backup path"),_T("?user/autoback")); - SetText(_T("Auto recovery path"),_T("?user/recovered")); SetInt(_T("Autoload linked files"),2); SetText(_T("Text actor separator"),_T(":")); SetText(_T("Text comment starter"),_T("#"));