Fix crash on OK-ing gain calculation dialog without entering anything.
authorCarl Hetherington <cth@carlh.net>
Sat, 22 Sep 2012 17:23:54 +0000 (18:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 22 Sep 2012 17:23:54 +0000 (18:23 +0100)
src/wx/film_editor.cc
src/wx/gain_calculator_dialog.cc

index c8ef0f233e8a6210ba44a327d9ea9912fd7796a8..71c48bd79d9b2c0fda2cb13578b7b2d11722d0ee 100644 (file)
@@ -648,6 +648,12 @@ FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
 {
        GainCalculatorDialog* d = new GainCalculatorDialog (this);
        d->ShowModal ();
+
+       if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
+               d->Destroy ();
+               return;
+       }
+       
        _audio_gain->SetValue (
                Config::instance()->sound_processor()->db_for_fader_change (
                        d->wanted_fader (),
index fcd54d4cfb76ccea0398c937db966c405acf78bc..3f07faf062e4239835d692f8466d30c438fb7822 100644 (file)
@@ -52,11 +52,19 @@ GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent)
 float
 GainCalculatorDialog::wanted_fader () const
 {
+       if (_wanted->GetValue().IsEmpty()) {
+               return 0;
+       }
+       
        return lexical_cast<float> (wx_to_std (_wanted->GetValue ()));
 }
 
 float
 GainCalculatorDialog::actual_fader () const
 {
+       if (_actual->GetValue().IsEmpty()) {
+               return 0;
+       }
+
        return lexical_cast<float> (wx_to_std (_actual->GetValue ()));
 }