1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-01 08:09:41 +02:00

Bug 2458 - Possible crash when clearing text field in Gain dialog

This commit is contained in:
Leland Lucius 2020-05-28 20:09:14 -05:00
parent cd38e0e76d
commit 8ae8e0f0a5

View File

@ -322,16 +322,25 @@ bool SliderDialog::TransferDataToWindow()
bool SliderDialog::TransferDataFromWindow()
{
double value;
// Bug #2458
//
// If the user clears the text control, the ToDouble below will NOT set "value"
// since it checks the length of the incoming string and bypasses setting it if
// it's empty. So initialize "value" for good measure and check the return value
// of ToDouble for success before using "value".
double value = 0.0;
mTextCtrl->GetValue().ToDouble(&value);
if (mStyle == DB_SLIDER)
value = DB_TO_LINEAR(value);
mSlider->Set(value);
if (mpOrigin) {
mpOrigin->Set(value);
mpOrigin->SendUpdate(value);
if (mTextCtrl->GetValue().ToDouble(&value))
{
if (mStyle == DB_SLIDER)
value = DB_TO_LINEAR(value);
mSlider->Set(value);
if (mpOrigin) {
mpOrigin->Set(value);
mpOrigin->SendUpdate(value);
}
}
return true;
}