Fix crash on double-click of show-audio button.
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Dec 2013 15:31:54 +0000 (15:31 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Dec 2013 15:31:54 +0000 (15:31 +0000)
ChangeLog
src/lib/audio_content.cc
src/lib/audio_content.h
src/wx/audio_dialog.cc
src/wx/audio_dialog.h

index 286a6e8..158ea05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-12-02  Carl Hetherington  <cth@carlh.net>
 
+       * Fix crash on double-click of "show audio" button (#278).
+
        * Version 1.40 released.
 
 2013-12-02  Carl Hetherington  <cth@carlh.net>
index 04823d1..97372b9 100644 (file)
@@ -119,17 +119,17 @@ AudioContent::set_audio_delay (int d)
        signal_changed (AudioContentProperty::AUDIO_DELAY);
 }
 
-void
+boost::signals2::connection
 AudioContent::analyse_audio (boost::function<void()> finished)
 {
        shared_ptr<const Film> film = _film.lock ();
-       if (!film) {
-               return;
-       }
+       assert (film);
        
        shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, dynamic_pointer_cast<AudioContent> (shared_from_this())));
-       job->Finished.connect (finished);
+       boost::signals2::connection c = job->Finished.connect (finished);
        JobManager::instance()->add (job);
+
+       return c;
 }
 
 boost::filesystem::path
index b100d7a..ca4a1f2 100644 (file)
@@ -58,7 +58,7 @@ public:
        virtual AudioMapping audio_mapping () const = 0;
        virtual void set_audio_mapping (AudioMapping) = 0;
 
-       void analyse_audio (boost::function<void()>);
+       boost::signals2::connection analyse_audio (boost::function<void()>);
        boost::filesystem::path audio_analysis_path () const;
 
        void set_audio_gain (float);
index 78f3dea..1bce228 100644 (file)
@@ -87,7 +87,7 @@ void
 AudioDialog::set_content (shared_ptr<AudioContent> c)
 {
        _content_changed_connection.disconnect ();
-       
+
        _content = c;
 
        try_to_load_analysis ();
@@ -104,9 +104,9 @@ AudioDialog::try_to_load_analysis ()
        if (!IsShown ()) {
                return;
        }
-       
+
        if (!boost::filesystem::exists (_content->audio_analysis_path())) {
-               _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
+               _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
                return;
        }
        
index 8623192..b425705 100644 (file)
@@ -47,4 +47,5 @@ private:
        wxCheckBox* _type_checkbox[AudioPoint::COUNT];
        wxSlider* _smoothing;
        boost::signals2::scoped_connection _content_changed_connection;
+       boost::signals2::scoped_connection _analysis_finished_connection;
 };