2019-06-06 15:21:15 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
AutoRecoveryDialog.cpp
|
|
|
|
|
|
|
|
Paul Licameli split from AutoRecovery.cpp
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include "AutoRecoveryDialog.h"
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
#include "ActiveProjects.h"
|
2019-06-06 15:21:15 +00:00
|
|
|
#include "FileNames.h"
|
|
|
|
#include "ProjectManager.h"
|
2020-07-25 23:47:30 +00:00
|
|
|
#include "ProjectFileIO.h"
|
2019-06-06 15:21:15 +00:00
|
|
|
#include "ShuttleGui.h"
|
|
|
|
#include "widgets/AudacityMessageBox.h"
|
|
|
|
#include "widgets/wxPanelWrapper.h"
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
#include <wx/dir.h>
|
2019-06-06 15:21:15 +00:00
|
|
|
#include <wx/evtloop.h>
|
|
|
|
#include <wx/filefn.h>
|
|
|
|
#include <wx/filename.h>
|
|
|
|
#include <wx/listctrl.h>
|
|
|
|
|
|
|
|
enum {
|
2020-07-23 06:19:29 +00:00
|
|
|
ID_QUIT_AUDACITY = 10000,
|
|
|
|
ID_DISCARD_SELECTED,
|
|
|
|
ID_RECOVER_SELECTED,
|
2020-07-26 07:01:37 +00:00
|
|
|
ID_SKIP,
|
2019-06-06 15:21:15 +00:00
|
|
|
ID_FILE_LIST
|
|
|
|
};
|
|
|
|
|
|
|
|
class AutoRecoveryDialog final : public wxDialogWrapper
|
|
|
|
{
|
|
|
|
public:
|
2020-07-25 23:47:30 +00:00
|
|
|
AutoRecoveryDialog(AudacityProject *proj);
|
2020-07-23 06:19:29 +00:00
|
|
|
|
|
|
|
bool HasRecoverables() const;
|
|
|
|
FilePaths GetRecoverables();
|
2019-06-06 15:21:15 +00:00
|
|
|
|
|
|
|
private:
|
2020-07-01 05:45:17 +00:00
|
|
|
void PopulateOrExchange(ShuttleGui &S);
|
2019-06-06 15:21:15 +00:00
|
|
|
void PopulateList();
|
2020-07-26 07:01:37 +00:00
|
|
|
bool HaveChecked();
|
2019-06-06 15:21:15 +00:00
|
|
|
|
|
|
|
void OnQuitAudacity(wxCommandEvent &evt);
|
2020-07-23 06:19:29 +00:00
|
|
|
void OnDiscardSelected(wxCommandEvent &evt);
|
|
|
|
void OnRecoverSelected(wxCommandEvent &evt);
|
2020-07-26 07:01:37 +00:00
|
|
|
void OnSkip(wxCommandEvent &evt);
|
2020-08-02 17:30:36 +00:00
|
|
|
void OnColumnClicked(wxListEvent &evt);
|
2020-07-26 07:01:37 +00:00
|
|
|
void OnItemActivated(wxListEvent &evt);
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
FilePaths mFiles;
|
2019-06-06 15:21:15 +00:00
|
|
|
wxListCtrl *mFileList;
|
2020-07-25 23:47:30 +00:00
|
|
|
AudacityProject *mProject;
|
2019-06-06 15:21:15 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
BEGIN_EVENT_TABLE(AutoRecoveryDialog, wxDialogWrapper)
|
|
|
|
EVT_BUTTON(ID_QUIT_AUDACITY, AutoRecoveryDialog::OnQuitAudacity)
|
|
|
|
EVT_BUTTON(ID_DISCARD_SELECTED, AutoRecoveryDialog::OnDiscardSelected)
|
|
|
|
EVT_BUTTON(ID_RECOVER_SELECTED, AutoRecoveryDialog::OnRecoverSelected)
|
2020-07-26 07:01:37 +00:00
|
|
|
EVT_BUTTON(ID_SKIP, AutoRecoveryDialog::OnSkip)
|
2020-08-02 17:30:36 +00:00
|
|
|
EVT_LIST_COL_CLICK(ID_FILE_LIST, AutoRecoveryDialog::OnColumnClicked)
|
2020-07-26 07:01:37 +00:00
|
|
|
EVT_LIST_ITEM_ACTIVATED(ID_FILE_LIST, AutoRecoveryDialog::OnItemActivated)
|
2020-07-23 06:19:29 +00:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2020-07-25 23:47:30 +00:00
|
|
|
AutoRecoveryDialog::AutoRecoveryDialog(AudacityProject *project)
|
2020-07-23 06:19:29 +00:00
|
|
|
: wxDialogWrapper(nullptr, wxID_ANY, XO("Automatic Crash Recovery"),
|
2020-07-01 05:45:17 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2020-07-31 23:24:32 +00:00
|
|
|
(wxDEFAULT_DIALOG_STYLE & (~wxCLOSE_BOX)) | wxRESIZE_BORDER), // no close box
|
2020-07-25 23:47:30 +00:00
|
|
|
mProject(project)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2019-12-08 05:25:47 +00:00
|
|
|
SetName();
|
2019-06-06 15:21:15 +00:00
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
PopulateOrExchange(S);
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
bool AutoRecoveryDialog::HasRecoverables() const
|
|
|
|
{
|
|
|
|
return mFiles.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FilePaths AutoRecoveryDialog::GetRecoverables()
|
|
|
|
{
|
|
|
|
return mFiles;
|
|
|
|
}
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-01 05:45:17 +00:00
|
|
|
void AutoRecoveryDialog::PopulateOrExchange(ShuttleGui &S)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
|
|
|
S.SetBorder(5);
|
2020-07-31 23:24:32 +00:00
|
|
|
S.StartVerticalLay(wxEXPAND, 1);
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2019-12-22 22:01:20 +00:00
|
|
|
S.AddVariableText(
|
2020-07-01 05:45:17 +00:00
|
|
|
XO("Some projects were not saved properly the last time Audacity was run.\nFortunately, the following projects can be automatically recovered:"),
|
2019-12-22 22:01:20 +00:00
|
|
|
false);
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-31 23:24:32 +00:00
|
|
|
S.StartStatic(XO("Recoverable projects"), 1);
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-23 06:19:29 +00:00
|
|
|
mFileList = S.Id(ID_FILE_LIST).AddListControlReportMode(
|
|
|
|
{
|
|
|
|
/*i18n-hint: (verb). It instruct the user to select items.*/
|
|
|
|
XO("Select"),
|
|
|
|
/*i18n-hint: (noun). It's the name of the project to recover.*/
|
|
|
|
XO("Name")
|
|
|
|
});
|
|
|
|
mFileList->EnableCheckBoxes();
|
2019-06-06 15:21:15 +00:00
|
|
|
PopulateList();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
2019-12-22 22:01:20 +00:00
|
|
|
S.AddVariableText(
|
|
|
|
XO("After recovery, save the project to save the changes to disk."),
|
|
|
|
false);
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-31 23:24:32 +00:00
|
|
|
S.StartHorizontalLay(wxALIGN_CENTRE, 0);
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-05-11 15:28:14 +00:00
|
|
|
S.Id(ID_QUIT_AUDACITY).AddButton(XXO("Quit Audacity"));
|
2020-07-23 06:19:29 +00:00
|
|
|
S.Id(ID_DISCARD_SELECTED).AddButton(XXO("Discard Selected"));
|
|
|
|
S.Id(ID_RECOVER_SELECTED).AddButton(XXO("Recover Selected"));
|
2020-07-26 07:01:37 +00:00
|
|
|
S.Id(ID_SKIP).AddButton(XXO("Skip"));
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
|
|
|
S.EndHorizontalLay();
|
|
|
|
}
|
|
|
|
S.EndVerticalLay();
|
|
|
|
|
|
|
|
Layout();
|
|
|
|
Fit();
|
|
|
|
SetMinSize(GetSize());
|
|
|
|
|
|
|
|
// Sometimes it centers on wxGTK and sometimes it doesn't.
|
|
|
|
// Yielding before centering seems to be a good workaround,
|
|
|
|
// but will leave to implement on a rainy day.
|
|
|
|
Center();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AutoRecoveryDialog::PopulateList()
|
|
|
|
{
|
2020-07-23 06:19:29 +00:00
|
|
|
wxString tempdir = FileNames::TempDir();
|
|
|
|
wxString pattern = wxT("*.") + FileNames::UnsavedProjectExtension();
|
|
|
|
FilePaths files;
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
wxDir::GetAllFiles(tempdir, &files, pattern, wxDIR_FILES);
|
|
|
|
|
|
|
|
FilePaths active = ActiveProjects::GetAll();
|
|
|
|
|
|
|
|
for (auto file : active)
|
|
|
|
{
|
|
|
|
wxFileName fn = file;
|
|
|
|
if (fn.FileExists())
|
|
|
|
{
|
|
|
|
FilePath fullPath = fn.GetFullPath();
|
|
|
|
if (files.Index(fullPath) == wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
files.push_back(fullPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-25 23:47:30 +00:00
|
|
|
FilePath activeFile;
|
|
|
|
if (mProject)
|
|
|
|
{
|
|
|
|
auto &projectFileIO = ProjectFileIO::Get(*mProject);
|
|
|
|
activeFile = projectFileIO.GetFileName();
|
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
mFiles.clear();
|
2019-06-06 15:21:15 +00:00
|
|
|
mFileList->DeleteAllItems();
|
2020-07-23 06:19:29 +00:00
|
|
|
long item = 0;
|
2020-07-26 07:01:37 +00:00
|
|
|
|
|
|
|
for (auto file : files)
|
2020-07-01 05:45:17 +00:00
|
|
|
{
|
2020-07-23 06:19:29 +00:00
|
|
|
wxFileName fn = file;
|
2020-07-25 23:47:30 +00:00
|
|
|
if (fn != activeFile)
|
2020-07-23 06:19:29 +00:00
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
mFiles.push_back(fn.GetFullPath());
|
|
|
|
mFileList->InsertItem(item, wxT(""));
|
|
|
|
mFileList->SetItem(item, 1, fn.GetName());
|
|
|
|
item++;
|
2020-07-23 06:19:29 +00:00
|
|
|
}
|
2020-07-01 05:45:17 +00:00
|
|
|
}
|
2020-07-31 23:24:32 +00:00
|
|
|
mFileList->SetMinSize(mFileList->GetBestSize());
|
2020-07-26 07:01:37 +00:00
|
|
|
mFileList->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
|
|
|
|
mFileList->SetColumnWidth(1, 500);
|
|
|
|
}
|
2020-07-23 06:19:29 +00:00
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
bool AutoRecoveryDialog::HaveChecked()
|
|
|
|
{
|
|
|
|
long item = -1;
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
item = mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
|
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (mFileList->IsItemChecked(item))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2020-07-23 06:19:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
AudacityMessageBox(XO("No projects selected"), XO("Automatic Crash Recovery"));
|
|
|
|
|
|
|
|
return false;
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
void AutoRecoveryDialog::OnQuitAudacity(wxCommandEvent &WXUNUSED(evt))
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
|
|
|
EndModal(ID_QUIT_AUDACITY);
|
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
void AutoRecoveryDialog::OnDiscardSelected(wxCommandEvent &WXUNUSED(evt))
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
if (!HaveChecked())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-06 15:21:15 +00:00
|
|
|
int ret = AudacityMessageBox(
|
2020-07-23 06:19:29 +00:00
|
|
|
XO("Are you sure you want to discard the selected projects?\n\n"
|
|
|
|
"Choosing \"Yes\" permanently deletes the selected projects immediately."),
|
2020-07-26 07:01:37 +00:00
|
|
|
XO("Automatic Crash Recovery"),
|
2019-12-07 19:30:07 +00:00
|
|
|
wxICON_QUESTION | wxYES_NO | wxNO_DEFAULT, this);
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
if (ret == wxNO)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
long item = -1;
|
|
|
|
while (true)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
item = mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
|
2020-07-23 06:19:29 +00:00
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!mFileList->IsItemChecked(item))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2020-07-28 01:56:29 +00:00
|
|
|
FilePath fileName = mFiles[item];
|
2020-07-01 05:45:17 +00:00
|
|
|
|
2020-07-28 01:56:29 +00:00
|
|
|
// Only remove it from disk if it appears to be a temporary file.
|
|
|
|
wxFileName file(fileName);
|
|
|
|
if (file.GetExt().IsSameAs(FileNames::UnsavedProjectExtension()))
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-28 01:56:29 +00:00
|
|
|
file.SetFullName(wxT(""));
|
2020-07-01 05:45:17 +00:00
|
|
|
|
2020-07-28 01:56:29 +00:00
|
|
|
wxFileName temp(FileNames::TempDir(), wxT(""));
|
|
|
|
if (file == temp)
|
2020-07-01 05:45:17 +00:00
|
|
|
{
|
2020-07-28 01:56:29 +00:00
|
|
|
if (wxRemoveFile(fileName))
|
|
|
|
{
|
|
|
|
if (wxFileExists(fileName + wxT("-shm")))
|
|
|
|
{
|
|
|
|
wxRemoveFile(fileName + wxT("-shm"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wxFileExists(fileName + wxT("-wal")))
|
|
|
|
{
|
|
|
|
wxRemoveFile(fileName + wxT("-wal"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wxFileExists(fileName + wxT("-journal")))
|
|
|
|
{
|
|
|
|
wxRemoveFile(fileName + wxT("-journal"));
|
|
|
|
}
|
|
|
|
}
|
2020-07-01 05:45:17 +00:00
|
|
|
}
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
2020-07-28 01:56:29 +00:00
|
|
|
|
|
|
|
// Forget all about it
|
|
|
|
ActiveProjects::Remove(fileName);
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
PopulateList();
|
|
|
|
|
|
|
|
if (mFileList->GetItemCount() == 0)
|
|
|
|
{
|
|
|
|
EndModal(ID_DISCARD_SELECTED);
|
|
|
|
}
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
void AutoRecoveryDialog::OnRecoverSelected(wxCommandEvent &WXUNUSED(evt))
|
2020-07-23 06:19:29 +00:00
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
if (!HaveChecked())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2020-07-23 06:19:29 +00:00
|
|
|
|
|
|
|
FilePaths files;
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
bool selected = false;
|
2020-07-23 06:19:29 +00:00
|
|
|
long item = -1;
|
|
|
|
while (true)
|
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
item = mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
|
2020-07-23 06:19:29 +00:00
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
if (!selected)
|
|
|
|
{
|
|
|
|
AudacityMessageBox(XO("No projects selected"), XO("Automatic Crash Recovery"));
|
|
|
|
}
|
2020-07-23 06:19:29 +00:00
|
|
|
break;
|
|
|
|
}
|
2020-07-26 07:01:37 +00:00
|
|
|
selected = true;
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
if (!mFileList->IsItemChecked(item))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
files.push_back(mFiles[item]);
|
|
|
|
}
|
|
|
|
|
|
|
|
mFiles = files;
|
|
|
|
|
|
|
|
EndModal(ID_RECOVER_SELECTED);
|
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
void AutoRecoveryDialog::OnSkip(wxCommandEvent &WXUNUSED(evt))
|
|
|
|
{
|
|
|
|
EndModal(ID_SKIP);
|
|
|
|
}
|
|
|
|
|
2020-08-02 17:30:36 +00:00
|
|
|
void AutoRecoveryDialog::OnColumnClicked(wxListEvent &evt)
|
|
|
|
{
|
|
|
|
if (evt.GetColumn() != 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
long item = -1;
|
|
|
|
while (true)
|
|
|
|
{
|
|
|
|
item = mFileList->GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_DONTCARE);
|
|
|
|
if (item == wxNOT_FOUND)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mFileList->CheckItem(item, !mFileList->IsItemChecked(item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-26 07:01:37 +00:00
|
|
|
void AutoRecoveryDialog::OnItemActivated(wxListEvent &evt)
|
|
|
|
{
|
|
|
|
long item = evt.GetIndex();
|
|
|
|
mFileList->CheckItem(item, !mFileList->IsItemChecked(item));
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2020-07-01 05:45:17 +00:00
|
|
|
static bool RecoverAllProjects(const FilePaths &files,
|
|
|
|
AudacityProject **pproj)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
|
|
|
// Open a project window for each auto save file
|
|
|
|
wxString filename;
|
|
|
|
|
2020-07-01 05:45:17 +00:00
|
|
|
for (int i = 0, cnt = files.size(); i < cnt; ++i)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-01 05:45:17 +00:00
|
|
|
AudacityProject *proj = nullptr;
|
2019-06-06 15:21:15 +00:00
|
|
|
if (*pproj)
|
|
|
|
{
|
|
|
|
// Reuse existing project window
|
|
|
|
proj = *pproj;
|
|
|
|
*pproj = NULL;
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
// Open project.
|
|
|
|
if (ProjectManager::OpenProject(proj, files[i], false) == nullptr)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
bool ShowAutoRecoveryDialogIfNeeded(AudacityProject **pproj, bool *didRecoverAnything)
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
|
|
|
if (didRecoverAnything)
|
2020-07-23 06:19:29 +00:00
|
|
|
{
|
2019-06-06 15:21:15 +00:00
|
|
|
*didRecoverAnything = false;
|
2020-07-23 06:19:29 +00:00
|
|
|
}
|
2020-07-01 05:45:17 +00:00
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
// Under wxGTK3, the auto recovery dialog will not get
|
|
|
|
// the focus since the project window hasn't been allowed
|
|
|
|
// to completely initialize.
|
|
|
|
//
|
|
|
|
// Yielding seems to allow the initialization to complete.
|
|
|
|
//
|
|
|
|
// Additionally, it also corrects a sizing issue in the dialog
|
|
|
|
// related to wxWidgets bug:
|
|
|
|
//
|
|
|
|
// http://trac.wxwidgets.org/ticket/16440
|
|
|
|
//
|
|
|
|
// This must be done before "dlg" is declared.
|
|
|
|
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
|
|
|
|
|
2020-07-25 23:47:30 +00:00
|
|
|
AutoRecoveryDialog dialog(*pproj);
|
2020-07-23 06:19:29 +00:00
|
|
|
|
|
|
|
if (dialog.HasRecoverables())
|
2019-06-06 15:21:15 +00:00
|
|
|
{
|
2020-07-23 06:19:29 +00:00
|
|
|
int ret = dialog.ShowModal();
|
|
|
|
|
2019-06-06 15:21:15 +00:00
|
|
|
switch (ret)
|
|
|
|
{
|
2020-07-26 07:01:37 +00:00
|
|
|
case ID_SKIP:
|
2020-07-23 06:19:29 +00:00
|
|
|
case ID_DISCARD_SELECTED:
|
|
|
|
success = true;
|
|
|
|
break;
|
2019-06-06 15:21:15 +00:00
|
|
|
|
2020-07-23 06:19:29 +00:00
|
|
|
case ID_RECOVER_SELECTED:
|
|
|
|
success = RecoverAllProjects(dialog.GetRecoverables(), pproj);
|
|
|
|
if (success)
|
|
|
|
{
|
|
|
|
if (didRecoverAnything)
|
|
|
|
{
|
|
|
|
*didRecoverAnything = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-06-06 15:21:15 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
// This includes ID_QUIT_AUDACITY
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2020-07-23 06:19:29 +00:00
|
|
|
|
|
|
|
return success;
|
2019-06-06 15:21:15 +00:00
|
|
|
}
|