Audacity 3.2.0
Classes | Enumerations | Functions
AutoRecoveryDialog.cpp File Reference
#include "AutoRecoveryDialog.h"
#include "ActiveProjects.h"
#include "ProjectManager.h"
#include "ProjectFileIO.h"
#include "ProjectFileManager.h"
#include "ShuttleGui.h"
#include "TempDirectory.h"
#include "AudacityMessageBox.h"
#include "wxPanelWrapper.h"
#include <wx/dir.h>
#include <wx/evtloop.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/listctrl.h>
Include dependency graph for AutoRecoveryDialog.cpp:

Go to the source code of this file.

Classes

class  AutoRecoveryDialog
 

Enumerations

enum  {
  ID_QUIT_AUDACITY = 10000 , ID_DISCARD_SELECTED , ID_RECOVER_SELECTED , ID_SKIP ,
  ID_FILE_LIST
}
 

Functions

static bool RecoverAllProjects (const FilePaths &files, AudacityProject *&pproj)
 
static void DiscardAllProjects (const FilePaths &files)
 
bool ShowAutoRecoveryDialogIfNeeded (AudacityProject *&pproj, bool *didRecoverAnything)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ID_QUIT_AUDACITY 
ID_DISCARD_SELECTED 
ID_RECOVER_SELECTED 
ID_SKIP 
ID_FILE_LIST 

Definition at line 28 of file AutoRecoveryDialog.cpp.

28 {
29 ID_QUIT_AUDACITY = 10000,
32 ID_SKIP,
34};
@ ID_FILE_LIST
@ ID_RECOVER_SELECTED
@ ID_DISCARD_SELECTED
@ ID_QUIT_AUDACITY

Function Documentation

◆ DiscardAllProjects()

static void DiscardAllProjects ( const FilePaths files)
static

Definition at line 443 of file AutoRecoveryDialog.cpp.

444{
445 // Open and close each file, invisibly, removing its Autosave blob
446 for (auto &file: files)
448}
static void DiscardAutosave(const FilePath &filename)

References ProjectFileManager::DiscardAutosave().

Referenced by ShowAutoRecoveryDialogIfNeeded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecoverAllProjects()

static bool RecoverAllProjects ( const FilePaths files,
AudacityProject *&  pproj 
)
static

Definition at line 419 of file AutoRecoveryDialog.cpp.

421{
422 // Open a project window for each auto save file
423 wxString filename;
424 bool result = true;
425
426 for (auto &file: files)
427 {
428 AudacityProject *proj = nullptr;
429 // Reuse any existing project window, which will be the empty project
430 // created at application startup
431 std::swap(proj, pproj);
432
433 // Open project.
434 if (ProjectManager::OpenProject(proj, file, false, true) == nullptr)
435 {
436 result = false;
437 }
438 }
439
440 return result;
441}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static AudacityProject * OpenProject(AudacityProject *pGivenProject, const FilePath &fileNameArg, bool addtohistory, bool reuseNonemptyProject)
Open a file into an AudacityProject, returning the project, or nullptr for failure.
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:628

References ProjectManager::OpenProject(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by ShowAutoRecoveryDialogIfNeeded().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShowAutoRecoveryDialogIfNeeded()

bool ShowAutoRecoveryDialogIfNeeded ( AudacityProject *&  pproj,
bool *  didRecoverAnything 
)

Definition at line 450 of file AutoRecoveryDialog.cpp.

451{
452 if (didRecoverAnything)
453 {
454 *didRecoverAnything = false;
455 }
456
457 bool success = true;
458
459 // Under wxGTK3, the auto recovery dialog will not get
460 // the focus since the project window hasn't been allowed
461 // to completely initialize.
462 //
463 // Yielding seems to allow the initialization to complete.
464 //
465 // Additionally, it also corrects a sizing issue in the dialog
466 // related to wxWidgets bug:
467 //
468 // http://trac.wxwidgets.org/ticket/16440
469 //
470 // This must be done before "dlg" is declared.
471 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
472
473 AutoRecoveryDialog dialog(pproj);
474
475 if (dialog.HasRecoverables())
476 {
477 int ret = dialog.ShowModal();
478
479 switch (ret)
480 {
481 case ID_SKIP:
482 success = true;
483 break;
484
486 DiscardAllProjects(dialog.GetRecoverables());
487 success = true;
488 break;
489
491 success = RecoverAllProjects(dialog.GetRecoverables(), pproj);
492 if (success)
493 {
494 if (didRecoverAnything)
495 {
496 *didRecoverAnything = true;
497 }
498 }
499 break;
500
501 default:
502 // This includes ID_QUIT_AUDACITY
503 return false;
504 }
505 }
506
507 return success;
508}
static void DiscardAllProjects(const FilePaths &files)
static bool RecoverAllProjects(const FilePaths &files, AudacityProject *&pproj)

References DiscardAllProjects(), AutoRecoveryDialog::GetRecoverables(), AutoRecoveryDialog::HasRecoverables(), ID_DISCARD_SELECTED, ID_RECOVER_SELECTED, ID_SKIP, and RecoverAllProjects().

Referenced by AudacityApp::InitPart2().

Here is the call graph for this function:
Here is the caller graph for this function: