1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-23 07:58:05 +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.
#if defined(__WXMAC__) && defined(__WXDEBUG__)
{
wxDialog *d = wxDynamicCast(wxGetTopLevelParent(FindFocus()), wxDialog);
wxASSERT((!d || !d->IsModal()));
wxDialog *dlg = wxDynamicCast(wxGetTopLevelParent(FindFocus()), wxDialog);
wxASSERT((!dlg || !dlg->IsModal()));
}
#endif
@ -1889,9 +1889,8 @@ void AudacityProject::OnStopSelect()
mViewInfo.sel1 = mViewInfo.sel0;
}
GetControlToolBar()->OnStop(evt);
ModifyState();
}
ModifyState();
}
void AudacityProject::OnToggleSoundActivated()
@ -2186,73 +2185,87 @@ void AudacityProject::OnSelContractRight()
//the current play position.
void AudacityProject::OnSetLeftSelection()
{
if (GetAudioIOToken()>0 &&
gAudioIO->IsStreamActive(GetAudioIOToken()))
{
double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel0 = indicator;
}
bool bSelChanged = false;
if ((GetAudioIOToken() > 0) && gAudioIO->IsStreamActive(GetAudioIOToken()))
{
double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel0 = indicator;
bSelChanged = true;
}
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"));
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;
}
bSelChanged = true;
}
}
if(mViewInfo.sel1 < mViewInfo.sel0)
if (mViewInfo.sel1 < mViewInfo.sel0)
{
mViewInfo.sel1 = mViewInfo.sel0;
bSelChanged = true;
}
ModifyState();
mTrackPanel->Refresh(false);
if (bSelChanged)
{
ModifyState();
mTrackPanel->Refresh(false);
}
}
void AudacityProject::OnSetRightSelection()
{
if (GetAudioIOToken()>0 &&
gAudioIO->IsStreamActive(GetAudioIOToken()))
{
double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel1 = indicator;
}
bool bSelChanged = false;
if ((GetAudioIOToken() > 0) && gAudioIO->IsStreamActive(GetAudioIOToken()))
{
double indicator = gAudioIO->GetStreamTime();
mViewInfo.sel1 = indicator;
bSelChanged = true;
}
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"));
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;
}
bSelChanged = true;
}
}
if(mViewInfo.sel0 > mViewInfo.sel1)
if (mViewInfo.sel0 > mViewInfo.sel1)
{
mViewInfo.sel0 = mViewInfo.sel1;
bSelChanged = true;
}
ModifyState();
mTrackPanel->Refresh(false);
if (bSelChanged)
{
ModifyState();
mTrackPanel->Refresh(false);
}
}
void AudacityProject::NextFrame()
@ -5167,9 +5180,9 @@ void AudacityProject::OnAddLabelPlaying()
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"));
RedrawProject();
}
@ -5341,8 +5354,8 @@ void AudacityProject::OnImportCleanSpeechPresets()
void AudacityProject::OnApplyChain()
{
BatchProcessDialog d(this);
d.ShowModal();
BatchProcessDialog dlg(this);
dlg.ShowModal();
// LL: See comments in ModifyUndoMenuItems() for info about this...
//
@ -5352,8 +5365,8 @@ void AudacityProject::OnApplyChain()
void AudacityProject::OnEditChains()
{
EditChainsDialog d(this);
d.ShowModal();
EditChainsDialog dlg(this);
dlg.ShowModal();
}
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???
// 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)
{
mTracks->Clear(true);

View File

@ -4017,7 +4017,7 @@ void TrackPanel::HandleResizeButtonUp(wxMouseEvent & event)
{
SetCapturedTrack( NULL );
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
@ -6479,7 +6479,7 @@ void TrackPanel::OnSetDisplay(wxCommandEvent & event)
UpdateVRuler(wt);
}
MakeParentModifyState();
MakeParentModifyState(); //v Doesn't really warrant AutoSave. Maybe add bWantAutoSave param if there are more.
mPopupMenuTarget = NULL;
Refresh(false);
}