From 1dd9fb73e28f079fb0d4ee46ab3e18008e42aca2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 16 Jun 2016 00:51:15 +0100 Subject: [PATCH] Potential fix for crash on loading a new film after starting an audio analysis. --- src/wx/audio_dialog.cc | 5 ++++- src/wx/audio_panel.cc | 10 ++++++++++ src/wx/audio_panel.h | 1 + src/wx/content_panel.cc | 2 ++ src/wx/content_panel.h | 3 ++- src/wx/dcp_panel.cc | 6 ++++++ 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index b2fb0efe5..c753de535 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -218,7 +218,10 @@ void AudioDialog::analysis_finished () { shared_ptr film = _film.lock (); - DCPOMATIC_ASSERT (film); + if (!film) { + /* This should not happen, but if it does we should just give up quietly */ + return; + } if (!boost::filesystem::exists (film->audio_analysis_path (_playlist))) { /* We analysed and still nothing showed up, so maybe it was cancelled or it failed. diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index a2ede0bd6..ab26329a4 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -362,3 +362,13 @@ AudioPanel::reference_clicked () d->set_reference_audio (_reference->GetValue ()); } + +void +AudioPanel::set_film (shared_ptr) +{ + /* We are changing film, so destroy any audio dialog for the old one */ + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } +} diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h index aabfd71c1..fe9f1cdec 100644 --- a/src/wx/audio_panel.h +++ b/src/wx/audio_panel.h @@ -38,6 +38,7 @@ public: void film_changed (Film::Property); void film_content_changed (int); void content_selection_changed (); + void set_film (boost::shared_ptr); private: void show_clicked (); diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index d1a00c021..b7878d3b3 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -403,6 +403,8 @@ ContentPanel::setup_sensitivity () void ContentPanel::set_film (shared_ptr film) { + _audio_panel->set_film (film); + _film = film; film_changed (Film::CONTENT); diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index fe48e1e93..e1a66770c 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -32,6 +32,7 @@ class wxListEvent; class TimelineDialog; class FilmEditor; class ContentSubPanel; +class AudioPanel; class Film; class FilmViewer; @@ -93,7 +94,7 @@ private: wxButton* _later; wxButton* _timeline; ContentSubPanel* _video_panel; - ContentSubPanel* _audio_panel; + AudioPanel* _audio_panel; ContentSubPanel* _subtitle_panel; ContentSubPanel* _timing_panel; std::list _panels; diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 66a084259..461aeca71 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -496,6 +496,12 @@ DCPPanel::dcp_content_type_changed () void DCPPanel::set_film (shared_ptr film) { + /* We are changing film, so destroy any audio dialog for the old one */ + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } + _film = film; film_changed (Film::NAME); -- 2.30.2