From: Carl Hetherington Date: Sat, 22 Sep 2012 17:23:54 +0000 (+0100) Subject: Fix crash on OK-ing gain calculation dialog without entering anything. X-Git-Tag: v2.0.48~1720^2~38 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=2367db77c5ad7e4c2319351bcc9c09b7fc387384;p=dcpomatic.git Fix crash on OK-ing gain calculation dialog without entering anything. --- diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index c8ef0f233..71c48bd79 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -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 (), diff --git a/src/wx/gain_calculator_dialog.cc b/src/wx/gain_calculator_dialog.cc index fcd54d4cf..3f07faf06 100644 --- a/src/wx/gain_calculator_dialog.cc +++ b/src/wx/gain_calculator_dialog.cc @@ -52,11 +52,19 @@ GainCalculatorDialog::GainCalculatorDialog (wxWindow* parent) float GainCalculatorDialog::wanted_fader () const { + if (_wanted->GetValue().IsEmpty()) { + return 0; + } + return lexical_cast (wx_to_std (_wanted->GetValue ())); } float GainCalculatorDialog::actual_fader () const { + if (_actual->GetValue().IsEmpty()) { + return 0; + } + return lexical_cast (wx_to_std (_actual->GetValue ())); }