1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-26 17:18:41 +02:00

further constraints, against negative pasted frequencies that wxValidator doesn't prevent

This commit is contained in:
v.audacity 2013-05-21 02:35:29 +00:00
parent 1589720d93
commit 588d2976b0

View File

@ -576,19 +576,15 @@ void ChangePitchDialog::OnText_FromFrequency(wxCommandEvent & WXUNUSED(event))
if (m_pTextCtrl_FromFrequency) {
wxString str = m_pTextCtrl_FromFrequency->GetValue();
// Empty string causes unpredictable results with ToDouble() and later calculations.
if (str.IsEmpty())
{
this->FindWindow(wxID_OK)->Disable();
return;
}
double newDouble;
str.ToDouble(&newDouble);
// Zero frequency makes no sense, but user might still be editing,
// Empty string causes unpredictable results with ToDouble() and later calculations.
// Non-positive frequency makes no sense, but user might still be editing,
// so it's not an error, but we do not want to update the values/controls.
if (newDouble == 0.0)
if (str.IsEmpty() || (newDouble <= 0.0) )
{
this->FindWindow(wxID_OK)->Disable();
this->FindWindow(ID_EFFECT_PREVIEW)->Disable();
return;
}
m_FromFrequency = newDouble;
@ -614,19 +610,15 @@ void ChangePitchDialog::OnText_ToFrequency(wxCommandEvent & WXUNUSED(event))
if (m_pTextCtrl_ToFrequency) {
wxString str = m_pTextCtrl_ToFrequency->GetValue();
// Empty string causes unpredictable results with ToDouble() and later calculations.
if (str.IsEmpty())
{
this->FindWindow(wxID_OK)->Disable();
return;
}
double newDouble;
str.ToDouble(&newDouble);
// Zero frequency makes no sense, but user might still be editing,
// Empty string causes unpredictable results with ToDouble() and later calculations.
// Non-positive frequency makes no sense, but user might still be editing,
// so it's not an error, but we do not want to update the values/controls.
if (newDouble == 0.0)
if (str.IsEmpty() || (newDouble <= 0.0) )
{
this->FindWindow(wxID_OK)->Disable();
this->FindWindow(ID_EFFECT_PREVIEW)->Disable();
return;
}
m_ToFrequency = newDouble;