Audacity  2.2.2
Classes | Macros | Typedefs | Functions
AutoRecovery.h File Reference
#include "Project.h"
#include "xml/XMLTagHandler.h"
#include "xml/XMLWriter.h"
#include <wx/debug.h>
#include <wx/ffile.h>
#include <wx/hashmap.h>
#include <wx/mstream.h>
#include <unordered_map>

Go to the source code of this file.

Classes

class  RecordingRecoveryHandler
 
class  AutoSaveFile
 a class wrapping reading and writing of arbitrary data in text or binary format to a file. More...
 

Macros

#define AutoSaveIdent   "<?xml autosave>"
 

Typedefs

using NameMap = std::unordered_map< wxString, short >
 
using IdMap = std::unordered_map< short, wxString >
 

Functions

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

Macro Definition Documentation

#define AutoSaveIdent   "<?xml autosave>"

AutoSaveFile

Definition at line 72 of file AutoRecovery.h.

Referenced by AutoSaveFile::Decode(), and AutoSaveFile::Write().

Typedef Documentation

using IdMap = std::unordered_map<short, wxString>

Definition at line 75 of file AutoRecovery.h.

using NameMap = std::unordered_map<wxString, short>

Definition at line 74 of file AutoRecovery.h.

Function Documentation

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

Definition at line 230 of file AutoRecovery.cpp.

References HaveFilesToRecover(), ID_RECOVER_ALL, ID_RECOVER_NONE, RecoverAllProjects(), and RemoveAllAutoSaveFiles().

Referenced by AudacityApp::OnInit().

232 {
233  if (didRecoverAnything)
234  *didRecoverAnything = false;
235  if (HaveFilesToRecover())
236  {
237  // Under wxGTK3, the auto recovery dialog will not get
238  // the focus since the project window hasn't been allowed
239  // to completely initialize.
240  //
241  // Yielding seems to allow the initialization to complete.
242  //
243  // Additionally, it also corrects a sizing issue in the dialog
244  // related to wxWidgets bug:
245  //
246  // http://trac.wxwidgets.org/ticket/16440
247  //
248  // This must be done before "dlg" is declared.
249  wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
250 
251  int ret = AutoRecoveryDialog{nullptr}.ShowModal();
252 
253  switch (ret)
254  {
255  case ID_RECOVER_NONE:
256  return RemoveAllAutoSaveFiles();
257 
258  case ID_RECOVER_ALL:
259  if (didRecoverAnything)
260  *didRecoverAnything = true;
261  return RecoverAllProjects(pproj);
262 
263  default:
264  // This includes ID_QUIT_AUDACITY
265  return false;
266  }
267  } else
268  {
269  // Nothing to recover, move along
270  return true;
271  }
272 }
static bool RecoverAllProjects(AudacityProject **pproj)
static bool RemoveAllAutoSaveFiles()
The AutoRecoveryDialog prompts the user whether to recover previous Audacity projects that were close...
static bool HaveFilesToRecover()