1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-26 09:28:07 +02:00

Review calls to AudacityProject::ModifyState() and TrackPanel::MakeParentModifyState() to possibly add param to make AudacityProject::ModifyState() optionally not call AutoSave(). There is only one place (TrackPanel::OnSetDisplay()) where autosave is definitely not necessary, so don't change it now.

Also made a few places (e.g., AudacityProject::OnSetLeftSelection()) call AudacityProject::ModifyState() only if the selection actually changed.
This commit is contained in:
v.audacity 2010-08-30 03:24:40 +00:00
parent 369ebe40a4
commit 961d8cdeca
3 changed files with 75 additions and 60 deletions

View File

@ -1279,8 +1279,8 @@ void AudacityProject::RebuildMenuBar()
// sync with wxWidgets idea of what it should be. // sync with wxWidgets idea of what it should be.
#if defined(__WXMAC__) && defined(__WXDEBUG__) #if defined(__WXMAC__) && defined(__WXDEBUG__)
{ {
wxDialog *d = wxDynamicCast(wxGetTopLevelParent(FindFocus()), wxDialog); wxDialog *dlg = wxDynamicCast(wxGetTopLevelParent(FindFocus()), wxDialog);
wxASSERT((!d || !d->IsModal())); wxASSERT((!dlg || !dlg->IsModal()));
} }
#endif #endif
@ -1889,9 +1889,8 @@ void AudacityProject::OnStopSelect()
mViewInfo.sel1 = mViewInfo.sel0; mViewInfo.sel1 = mViewInfo.sel0;
} }
GetControlToolBar()->OnStop(evt); GetControlToolBar()->OnStop(evt);
ModifyState();
} }
ModifyState();
} }
void AudacityProject::OnToggleSoundActivated() void AudacityProject::OnToggleSoundActivated()
@ -2186,73 +2185,87 @@ void AudacityProject::OnSelContractRight()
//the current play position. //the current play position.
void AudacityProject::OnSetLeftSelection() void AudacityProject::OnSetLeftSelection()
{ {
if (GetAudioIOToken()>0 && bool bSelChanged = false;
gAudioIO->IsStreamActive(GetAudioIOToken())) if ((GetAudioIOToken() > 0) && gAudioIO->IsStreamActive(GetAudioIOToken()))
{ {
double indicator = gAudioIO->GetStreamTime(); double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel0 = indicator; mViewInfo.sel0 = indicator;
} bSelChanged = true;
}
else else
{
TimeDialog dlg(this, _("Set Left Selection Boundary"), _("Position"));
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT(""));
dlg.SetFormatString(fmt);
dlg.SetSampleRate(mRate);
dlg.SetTimeValue(mViewInfo.sel0);
if (wxID_OK == dlg.ShowModal())
{ {
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT("")); //Get the value from the dialog
mViewInfo.sel0 = dlg.GetTimeValue();
//Make sure it is 'legal'
if (mViewInfo.sel0 < 0.0)
mViewInfo.sel0 = 0.0;
TimeDialog D(this, _("Set Left Selection Boundary"), _("Position")); bSelChanged = true;
D.SetSampleRate(mRate);
D.SetFormatString(fmt);
D.SetTimeValue(mViewInfo.sel0);
if(wxID_OK==D.ShowModal() )
{
//Get the value from the dialog
mViewInfo.sel0 = D.GetTimeValue();
//Make sure it is 'legal'
if(mViewInfo.sel0 < 0.0)
mViewInfo.sel0 = 0.0;
}
} }
}
if(mViewInfo.sel1 < mViewInfo.sel0) if (mViewInfo.sel1 < mViewInfo.sel0)
{
mViewInfo.sel1 = mViewInfo.sel0; mViewInfo.sel1 = mViewInfo.sel0;
bSelChanged = true;
}
ModifyState(); if (bSelChanged)
{
mTrackPanel->Refresh(false); ModifyState();
mTrackPanel->Refresh(false);
}
} }
void AudacityProject::OnSetRightSelection() void AudacityProject::OnSetRightSelection()
{ {
if (GetAudioIOToken()>0 && bool bSelChanged = false;
gAudioIO->IsStreamActive(GetAudioIOToken())) if ((GetAudioIOToken() > 0) && gAudioIO->IsStreamActive(GetAudioIOToken()))
{ {
double indicator = gAudioIO->GetStreamTime(); double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel1 = indicator; mViewInfo.sel1 = indicator;
} bSelChanged = true;
}
else else
{
TimeDialog dlg(this, _("Set Right Selection Boundary"), _("Position"));
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT(""));
dlg.SetFormatString(fmt);
dlg.SetSampleRate(mRate);
dlg.SetTimeValue(mViewInfo.sel1);
if (wxID_OK == dlg.ShowModal())
{ {
wxString fmt = gPrefs->Read(wxT("/SelectionFormat"), wxT("")); //Get the value from the dialog
mViewInfo.sel1 = dlg.GetTimeValue();
//Make sure it is 'legal'
if(mViewInfo.sel1 < 0)
mViewInfo.sel1 = 0;
TimeDialog D(this, _("Set Right Selection Boundary"), _("Position")); bSelChanged = true;
D.SetSampleRate(mRate);
D.SetFormatString(fmt);
D.SetTimeValue(mViewInfo.sel1);
if(wxID_OK==D.ShowModal() )
{
//Get the value from the dialog
mViewInfo.sel1 = D.GetTimeValue();
//Make sure it is 'legal'
if(mViewInfo.sel1 < 0)
mViewInfo.sel1 = 0;
}
} }
}
if(mViewInfo.sel0 > mViewInfo.sel1) if (mViewInfo.sel0 > mViewInfo.sel1)
{
mViewInfo.sel0 = mViewInfo.sel1; mViewInfo.sel0 = mViewInfo.sel1;
bSelChanged = true;
}
ModifyState(); if (bSelChanged)
{
mTrackPanel->Refresh(false); ModifyState();
mTrackPanel->Refresh(false);
}
} }
void AudacityProject::NextFrame() void AudacityProject::NextFrame()
@ -5167,9 +5180,9 @@ void AudacityProject::OnAddLabelPlaying()
void AudacityProject::OnEditLabels() void AudacityProject::OnEditLabels()
{ {
LabelDialog d(this, mDirManager, mTracks, mViewInfo, mRate); LabelDialog dlg(this, mDirManager, mTracks, mViewInfo, mRate);
if (d.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
PushState(_("Edited labels"), _("Label")); PushState(_("Edited labels"), _("Label"));
RedrawProject(); RedrawProject();
} }
@ -5341,8 +5354,8 @@ void AudacityProject::OnImportCleanSpeechPresets()
void AudacityProject::OnApplyChain() void AudacityProject::OnApplyChain()
{ {
BatchProcessDialog d(this); BatchProcessDialog dlg(this);
d.ShowModal(); dlg.ShowModal();
// LL: See comments in ModifyUndoMenuItems() for info about this... // LL: See comments in ModifyUndoMenuItems() for info about this...
// //
@ -5352,8 +5365,8 @@ void AudacityProject::OnApplyChain()
void AudacityProject::OnEditChains() void AudacityProject::OnEditChains()
{ {
EditChainsDialog d(this); EditChainsDialog dlg(this);
d.ShowModal(); dlg.ShowModal();
} }
wxString AudacityProject::BuildCleanFileName(wxString fileName) wxString AudacityProject::BuildCleanFileName(wxString fileName)

View File

@ -3543,6 +3543,8 @@ void AudacityProject::ModifyState()
} }
// LL: Is there a memory leak here as "l" and "t" are not deleted??? // LL: Is there a memory leak here as "l" and "t" are not deleted???
// Vaughan, 2010-08-29: No, as "l" is a TrackList* of an Undo stack state.
// Need to keep it and its tracks "t" available for Undo/Redo/SetStateTo.
void AudacityProject::PopState(TrackList * l) void AudacityProject::PopState(TrackList * l)
{ {
mTracks->Clear(true); mTracks->Clear(true);

View File

@ -4017,7 +4017,7 @@ void TrackPanel::HandleResizeButtonUp(wxMouseEvent & event)
{ {
SetCapturedTrack( NULL ); SetCapturedTrack( NULL );
MakeParentRedrawScrollbars(); MakeParentRedrawScrollbars();
MakeParentModifyState(); MakeParentModifyState(); //v Probably doesn't really warrant AutoSave. Maybe add bWantAutoSave param if there are more.
} }
/// Resize dragging means that the mouse button IS down and has moved /// Resize dragging means that the mouse button IS down and has moved
@ -6479,7 +6479,7 @@ void TrackPanel::OnSetDisplay(wxCommandEvent & event)
UpdateVRuler(wt); UpdateVRuler(wt);
} }
MakeParentModifyState(); MakeParentModifyState(); //v Doesn't really warrant AutoSave. Maybe add bWantAutoSave param if there are more.
mPopupMenuTarget = NULL; mPopupMenuTarget = NULL;
Refresh(false); Refresh(false);
} }