| 366 | } |
| 367 | |
| 368 | void AegisubApp::UnhandledException(bool stackWalk) { |
| 369 | #if (!defined(_DEBUG) || defined(WITH_EXCEPTIONS)) && (wxUSE_ON_FATAL_EXCEPTION+0) |
| 370 | bool any = false; |
| 371 | agi::fs::path path; |
| 372 | for (auto& frame : frames) { |
| 373 | auto c = frame->context.get(); |
| 374 | if (!c || !c->ass || !c->subsController) continue; |
| 375 | |
| 376 | path = config::path->Decode("?user/recovered"); |
| 377 | agi::fs::CreateDirectory(path); |
| 378 | |
| 379 | auto filename = c->subsController->Filename().stem(); |
| 380 | filename.replace_extension(agi::format("%s.ass", agi::util::strftime("%Y-%m-%d-%H-%M-%S"))); |
| 381 | path /= filename; |
| 382 | c->subsController->Save(path); |
| 383 | |
| 384 | any = true; |
| 385 | } |
| 386 | |
| 387 | if (stackWalk) |
| 388 | crash_writer::Write(); |
| 389 | |
| 390 | if (any) { |
| 391 | // Inform user of crash. |
| 392 | wxMessageBox(agi::wxformat(exception_message, path), _("Program error"), wxOK | wxICON_ERROR | wxCENTER, nullptr); |
| 393 | } |
| 394 | else if (LastStartupState) { |
| 395 | wxMessageBox(fmt_wx("Aegisub has crashed while starting up!\n\nThe last startup step attempted was: %s.", LastStartupState), _("Program error"), wxOK | wxICON_ERROR | wxCENTER); |
| 396 | } |
| 397 | #endif |
| 398 | } |
| 399 | |
| 400 | void AegisubApp::OnUnhandledException() { |
| 401 | UnhandledException(false); |