1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-21 14:50:06 +02:00

Fix Bug 163 - Aborting a track name change writes a name change to history.

The logic was flawed -- did updates and PushState even when user canceled or hit OK with a blank name.
This commit is contained in:
v.audacity 2010-07-30 22:03:59 +00:00
parent 62689e9e70
commit afd7dec991

View File

@ -6752,31 +6752,32 @@ void TrackPanel::OnChangeOctave(wxCommandEvent & event)
void TrackPanel::OnSetName(wxCommandEvent &event)
{
Track *t = mPopupMenuTarget;
if (t) {
wxString defaultStr = t->GetName();
wxString newName = wxGetTextFromUser(_("Change track name to:"),
_("Track Name"), defaultStr);
//if we have a linked channel this name should change as well (otherwise sort by name and time will crash)
if (newName != wxT("")) {
t->SetName(newName);
if(t->GetLinked())
if (t)
{
wxString oldName = t->GetName();
wxString newName =
wxGetTextFromUser(_("Change track name to:"),
_("Track Name"), oldName);
if (newName != wxT("")) // wxGetTextFromUser returns empty string on Cancel.
{
t->SetName(newName);
// if we have a linked channel this name should change as well
// (otherwise sort by name and time will crash).
if (t->GetLinked())
t->GetLink()->SetName(newName);
}
}
MixerBoard* pMixerBoard = this->GetMixerBoard();
if (pMixerBoard && (t->GetKind() == Track::Wave))
pMixerBoard->UpdateName((WaveTrack*)t);
MakeParentPushState(wxString::Format(_("Renamed '%s' to '%s'"),
defaultStr.c_str(),
oldName.c_str(),
newName.c_str()),
_("Name Change"));
Refresh(false);
}
}
}
/// Cut selected text if cut menu item is selected