Don't reuse EditActions::DoUndo...

... instead, when timer recording is cancelled, don't push state and pop it
at once, but just roll it back.
This commit is contained in:
Paul Licameli 2019-06-21 20:22:20 -04:00
parent f8c40dc8e7
commit 684a948fd2
3 changed files with 14 additions and 19 deletions

View File

@ -110,7 +110,6 @@ bool DoEditMetadata(
AudacityProject &project,
const wxString &title, const wxString &shortUndoDescription, bool force );
void DoReloadPreferences( AudacityProject & );
void DoUndo( AudacityProject &project );
}
/// Namespace for functions for View menu

View File

@ -17,7 +17,6 @@ Paul Licameli split from ProjectManager.cpp
#include "AutoRecovery.h"
#include "DirManager.h"
#include "LabelTrack.h"
#include "Menus.h"
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectFileIO.h"
@ -25,6 +24,7 @@ Paul Licameli split from ProjectManager.cpp
#include "ProjectSettings.h"
#include "ProjectWindow.h"
#include "TimeTrack.h"
#include "UndoManager.h"
#include "toolbars/ControlToolBar.h"
#include "widgets/ErrorDialog.h"
#include "widgets/Warning.h"
@ -135,16 +135,17 @@ You are saving directly to a slow external storage device\n\
_("Turn off dropout detection"));
}
// Add to history
auto &history = ProjectHistory::Get( project );
history.PushState(_("Recorded Audio"), _("Record"));
// Reset timer record
if (IsTimerRecordCancelled())
{
EditActions::DoUndo( project );
if (IsTimerRecordCancelled()) {
// discard recording
history.RollbackState();
// Reset timer record
ResetTimerRecordCancelled();
}
else
// Add to history
history.PushState(_("Recorded Audio"), _("Record"));
// Refresh the project window
window.FixScrollbars();

View File

@ -235,8 +235,13 @@ bool DoEditMetadata
return false;
}
void DoUndo(AudacityProject &project)
// Menu handler functions
struct Handler : CommandHandlerObject {
void OnUndo(const CommandContext &context)
{
auto &project = context.project;
auto &trackPanel = TrackPanel::Get( project );
auto &undoManager = UndoManager::Get( project );
auto &window = ProjectWindow::Get( project );
@ -257,16 +262,6 @@ void DoUndo(AudacityProject &project)
trackPanel.EnsureVisible(trackPanel.GetFirstSelectedTrack());
}
// Menu handler functions
struct Handler : CommandHandlerObject {
void OnUndo(const CommandContext &context)
{
DoUndo(context.project);
}
void OnRedo(const CommandContext &context)
{
auto &project = context.project;