Potential fix for crash on loading a new film after starting an audio analysis.
authorCarl Hetherington <cth@carlh.net>
Wed, 15 Jun 2016 23:51:15 +0000 (00:51 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 15 Jun 2016 23:51:15 +0000 (00:51 +0100)
src/wx/audio_dialog.cc
src/wx/audio_panel.cc
src/wx/audio_panel.h
src/wx/content_panel.cc
src/wx/content_panel.h
src/wx/dcp_panel.cc

index b2fb0efe5d4aa2b2341d686ca8b3fdce170626fe..c753de535cb8d49f1e5e74d7ba7cc0abd4a868a1 100644 (file)
@@ -218,7 +218,10 @@ void
 AudioDialog::analysis_finished ()
 {
        shared_ptr<const Film> film = _film.lock ();
 AudioDialog::analysis_finished ()
 {
        shared_ptr<const Film> 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.
 
        if (!boost::filesystem::exists (film->audio_analysis_path (_playlist))) {
                /* We analysed and still nothing showed up, so maybe it was cancelled or it failed.
index a2ede0bd64ba63e15e4e4e82b12513d995380c61..ab26329a4b878a564ecf9cd96e9eed8890f674db 100644 (file)
@@ -362,3 +362,13 @@ AudioPanel::reference_clicked ()
 
        d->set_reference_audio (_reference->GetValue ());
 }
 
        d->set_reference_audio (_reference->GetValue ());
 }
+
+void
+AudioPanel::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;
+       }
+}
index aabfd71c17ae262eb6aab4841e52634cd4b3d185..fe9f1cdec59b536ce379641783d8ca986809bd55 100644 (file)
@@ -38,6 +38,7 @@ public:
        void film_changed (Film::Property);
        void film_content_changed (int);
        void content_selection_changed ();
        void film_changed (Film::Property);
        void film_content_changed (int);
        void content_selection_changed ();
+       void set_film (boost::shared_ptr<Film>);
 
 private:
        void show_clicked ();
 
 private:
        void show_clicked ();
index d1a00c02122ba354fdfdd4ea03146df1fc53b302..b7878d3b3147fddd3a9c00bb43daabc5145bcbe6 100644 (file)
@@ -403,6 +403,8 @@ ContentPanel::setup_sensitivity ()
 void
 ContentPanel::set_film (shared_ptr<Film> film)
 {
 void
 ContentPanel::set_film (shared_ptr<Film> film)
 {
+       _audio_panel->set_film (film);
+
        _film = film;
 
        film_changed (Film::CONTENT);
        _film = film;
 
        film_changed (Film::CONTENT);
index fe48e1e93d12246eff6183a6b7452116d68ba0f4..e1a66770c446633fcf72cfda2d9140b26833c26e 100644 (file)
@@ -32,6 +32,7 @@ class wxListEvent;
 class TimelineDialog;
 class FilmEditor;
 class ContentSubPanel;
 class TimelineDialog;
 class FilmEditor;
 class ContentSubPanel;
+class AudioPanel;
 class Film;
 class FilmViewer;
 
 class Film;
 class FilmViewer;
 
@@ -93,7 +94,7 @@ private:
        wxButton* _later;
        wxButton* _timeline;
        ContentSubPanel* _video_panel;
        wxButton* _later;
        wxButton* _timeline;
        ContentSubPanel* _video_panel;
-       ContentSubPanel* _audio_panel;
+       AudioPanel* _audio_panel;
        ContentSubPanel* _subtitle_panel;
        ContentSubPanel* _timing_panel;
        std::list<ContentSubPanel *> _panels;
        ContentSubPanel* _subtitle_panel;
        ContentSubPanel* _timing_panel;
        std::list<ContentSubPanel *> _panels;
index 66a0842596cd50d1c85ab544ab8e59c6ac3e71c1..461aeca714db21cb4cb14630d7eede9ef4d201a1 100644 (file)
@@ -496,6 +496,12 @@ DCPPanel::dcp_content_type_changed ()
 void
 DCPPanel::set_film (shared_ptr<Film> film)
 {
 void
 DCPPanel::set_film (shared_ptr<Film> 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);
        _film = film;
 
        film_changed (Film::NAME);