forked from mia/Aegisub
Vastly simplify saving of backup .ass files when crashing.
* Remove "Autorecovery path" option, this should not be user configurable. * Crashes are now saved as recovered/YYYY-MM-DD-HHMMSS_<name>.ass (no pruning) Originally committed to SVN as r3472.
This commit is contained in:
parent
01df6ba169
commit
78b0765608
3 changed files with 31 additions and 46 deletions
|
@ -194,14 +194,6 @@ DialogOptions::DialogOptions(wxWindow *parent)
|
||||||
browse = new BrowseButton(filePage,-1,_T(""),BROWSE_FOLDER);
|
browse = new BrowseButton(filePage,-1,_T(""),BROWSE_FOLDER);
|
||||||
browse->Bind(edit);
|
browse->Bind(edit);
|
||||||
fileSizer4->Add(browse,0,wxEXPAND);
|
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);
|
fileSizer4->AddGrowableCol(1,1);
|
||||||
|
|
||||||
// Third static box
|
// Third static box
|
||||||
|
|
|
@ -282,40 +282,36 @@ int AegisubApp::OnExit() {
|
||||||
/// Message displayed when an exception has occurred.
|
/// 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.");
|
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() {
|
void AegisubApp::OnUnhandledException() {
|
||||||
// Attempt to recover file
|
// Current filename if any.
|
||||||
wxFileName origfile(AssFile::top->filename);
|
wxFileName file(AssFile::top->filename);
|
||||||
wxString path = Options.AsText(_T("Auto recovery path"));
|
if (!file.HasName()) file.SetName(_T("untitled"));
|
||||||
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
|
||||||
wxFileName dstpath(path);
|
// Set path and create if it doesn't exist.
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
file.SetPath(StandardPaths::DecodePath(_T("?user/recovered")));
|
||||||
path += _T("/");
|
if (!file.DirExists()) file.Mkdir();
|
||||||
dstpath.Assign(path);
|
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
// Save file
|
||||||
wxString filename = path + origfile.GetName() + _T(".RECOVER.ass");
|
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);
|
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);
|
wxMessageBox(wxString::Format(exception_message, filename.c_str()), _("Program error"), wxOK | wxICON_ERROR, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Called during a fatal exception.
|
||||||
|
|
||||||
/// @brief Fatal exception
|
|
||||||
///
|
|
||||||
void AegisubApp::OnFatalException() {
|
void AegisubApp::OnFatalException() {
|
||||||
// Attempt to recover file
|
// Current filename if any.
|
||||||
wxFileName origfile(AssFile::top->filename);
|
wxFileName file(AssFile::top->filename);
|
||||||
wxString path = Options.AsText(_T("Auto recovery path"));
|
if (!file.HasName()) file.SetName(_T("untitled"));
|
||||||
if (path.IsEmpty()) path = StandardPaths::DecodePath(_T("?user/"));
|
|
||||||
wxFileName dstpath(path);
|
// Set path and create if it doesn't exist.
|
||||||
if (!dstpath.IsAbsolute()) path = StandardPaths::DecodePathMaybeRelative(path, _T("?user/"));
|
file.SetPath(StandardPaths::DecodePath(_T("?user/recovered")));
|
||||||
path += _T("/");
|
if (!file.DirExists()) file.Mkdir();
|
||||||
dstpath.Assign(path);
|
|
||||||
if (!dstpath.DirExists()) wxMkdir(path);
|
// Save file
|
||||||
wxString filename = path + origfile.GetName() + _T(".RECOVER.ass");
|
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);
|
AssFile::top->Save(filename,false,false);
|
||||||
|
|
||||||
#if wxUSE_STACKWALKER == 1
|
#if wxUSE_STACKWALKER == 1
|
||||||
|
@ -323,18 +319,17 @@ void AegisubApp::OnFatalException() {
|
||||||
StackWalker walker(_T("Fatal exception"));
|
StackWalker walker(_T("Fatal exception"));
|
||||||
walker.WalkFromException();
|
walker.WalkFromException();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Inform user of crash
|
// 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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
#ifdef wxUSE_STACKWALKER
|
||||||
// Stack walker
|
|
||||||
#if wxUSE_STACKWALKER == 1
|
|
||||||
|
|
||||||
/// @brief DOCME
|
/// @brief Callback to format a single frame
|
||||||
/// @param frame
|
/// @param frame frame to parse.
|
||||||
///
|
///
|
||||||
void StackWalker::OnStackFrame(const wxStackFrame &frame) {
|
void StackWalker::OnStackFrame(const wxStackFrame &frame) {
|
||||||
wxString dst = wxString::Format(_T("%03i - 0x%08X: "),frame.GetLevel(),frame.GetAddress()) + frame.GetName();
|
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
|
/// @brief Called at the start of walking the stack.
|
||||||
/// @param cause
|
/// @param cause cause of the crash.
|
||||||
///
|
///
|
||||||
StackWalker::StackWalker(wxString cause) {
|
StackWalker::StackWalker(wxString cause) {
|
||||||
file.open(wxString(StandardPaths::DecodePath(_T("?user/crashlog.txt"))).mb_str(),std::ios::out | std::ios::app);
|
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() {
|
StackWalker::~StackWalker() {
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
char dashes[1024];
|
char dashes[1024];
|
||||||
|
|
|
@ -116,7 +116,6 @@ void OptionsManager::LoadDefaults(bool onlyDefaults,bool doOverride) {
|
||||||
SetText(_T("Auto save path"),_T("?user/autosave"));
|
SetText(_T("Auto save path"),_T("?user/autosave"));
|
||||||
SetBool(_T("Auto backup"),true);
|
SetBool(_T("Auto backup"),true);
|
||||||
SetText(_T("Auto backup path"),_T("?user/autoback"));
|
SetText(_T("Auto backup path"),_T("?user/autoback"));
|
||||||
SetText(_T("Auto recovery path"),_T("?user/recovered"));
|
|
||||||
SetInt(_T("Autoload linked files"),2);
|
SetInt(_T("Autoload linked files"),2);
|
||||||
SetText(_T("Text actor separator"),_T(":"));
|
SetText(_T("Text actor separator"),_T(":"));
|
||||||
SetText(_T("Text comment starter"),_T("#"));
|
SetText(_T("Text comment starter"),_T("#"));
|
||||||
|
|
Loading…
Reference in a new issue