Hand-apply 33b76b675d747fd828aba91d9d857227cb8a8244 from master; make sure signals...
authorCarl Hetherington <cth@carlh.net>
Mon, 16 Mar 2015 22:25:57 +0000 (22:25 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 16 Mar 2015 22:25:57 +0000 (22:25 +0000)
21 files changed:
TO_PORT
src/lib/encoder.cc
src/lib/encoder.h
src/lib/film.cc
src/lib/film.h
src/lib/server_finder.cc
src/lib/server_finder.h
src/wx/audio_panel.cc
src/wx/audio_panel.h
src/wx/config_dialog.cc
src/wx/content_colour_conversion_dialog.cc
src/wx/content_colour_conversion_dialog.h
src/wx/content_menu.cc
src/wx/content_menu.h
src/wx/hints_dialog.cc
src/wx/hints_dialog.h
src/wx/job_manager_view.cc
src/wx/properties_dialog.cc
src/wx/properties_dialog.h
src/wx/servers_list_dialog.cc
src/wx/servers_list_dialog.h

diff --git a/TO_PORT b/TO_PORT
index 0eae6bfa18e52d3119020118bd6aab0562812e98..f8b67626c38074278febaa91540809c567962d62 100644 (file)
--- a/TO_PORT
+++ b/TO_PORT
@@ -1,4 +1,3 @@
-bb2bdf010dd2ea813f9ac7af5023ce39cf14f572
 c065accc4b4c6ed268e7fccea77a958473be7785
 7ba9dcdbfe8f0d94ad9887843995c152c45dfe9e
 e30fd8d
index 6b520571a7430efd7f9a21636cf3d8402af2f827..2a60268791134ae37d956face1349a2847f5450f 100644 (file)
@@ -93,7 +93,9 @@ Encoder::begin ()
                _threads.push_back (new boost::thread (boost::bind (&Encoder::encoder_thread, this, optional<ServerDescription> ())));
        }
 
-       ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
+       if (!ServerFinder::instance()->disabled ()) {
+               _server_found_connection = ServerFinder::instance()->connect (boost::bind (&Encoder::server_found, this, _1));
+       }
 }
 
 void
index 694c9bf1fee1a140fd6f9ac4ab5521ad261419cd..a4fe558740de69b8673de52027137120e3d06d58 100644 (file)
@@ -114,6 +114,8 @@ private:
 
        boost::shared_ptr<Writer> _writer;
        Waker _waker;
+
+       boost::signals2::scoped_connection _server_found_connection;
 };
 
 #endif
index c695a7d4b19fcdd30920d3606379f5ebb1391574..0b48bf7b12d34eefcd280c06add697e1b56aecd9 100644 (file)
@@ -136,8 +136,8 @@ Film::Film (boost::filesystem::path dir, bool log)
 {
        set_isdcf_date_today ();
 
-       _playlist->Changed.connect (bind (&Film::playlist_changed, this));
-       _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
+       _playlist_changed_connection = _playlist->Changed.connect (bind (&Film::playlist_changed, this));
+       _playlist_content_changed_connection = _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
        
        /* Make state.directory a complete path without ..s (where possible)
           (Code swiped from Adam Bowen on stackoverflow)
@@ -167,6 +167,13 @@ Film::Film (boost::filesystem::path dir, bool log)
        _playlist->set_sequence_video (_sequence_video);
 }
 
+Film::~Film ()
+{
+       for (list<boost::signals2::connection>::const_iterator i = _job_connections.begin(); i != _job_connections.end(); ++i) {
+               i->disconnect ();
+       }
+}      
+
 string
 Film::video_identifier () const
 {
@@ -937,7 +944,11 @@ Film::examine_and_add_content (shared_ptr<Content> c)
        }
                        
        shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
-       j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)));
+
+       _job_connections.push_back (
+               j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)))
+               );
+       
        JobManager::instance()->add (j);
 }
 
index 2de06515965d785c0e5e4ccb5e6ef1a50a6914bb..c3ab9f2ff550de1a65cd79a2924b36c13b293122 100644 (file)
@@ -60,6 +60,7 @@ class Film : public boost::enable_shared_from_this<Film>, public boost::noncopya
 {
 public:
        Film (boost::filesystem::path, bool log = true);
+       ~Film ();
 
        boost::filesystem::path info_dir () const;
        boost::filesystem::path j2c_path (int, Eyes, bool) const;
@@ -341,6 +342,10 @@ private:
        /** true if our state has changed since we last saved it */
        mutable bool _dirty;
 
+       boost::signals2::scoped_connection _playlist_changed_connection;
+       boost::signals2::scoped_connection _playlist_content_changed_connection;
+       std::list<boost::signals2::connection> _job_connections;
+
        friend struct paths_test;
        friend struct film_metadata_test;
 };
index bef00702f800c8ae7d503304b058d6ee746d6b43..d62531d9f7b634e6534033bb4bd426273ee32d4e 100644 (file)
@@ -192,13 +192,9 @@ ServerFinder::server_found (string ip) const
        return i != _servers.end ();
 }
 
-void
+boost::signals2::connection
 ServerFinder::connect (boost::function<void (ServerDescription)> fn)
 {
-       if (_disabled) {
-               return;
-       }
-       
        boost::mutex::scoped_lock lm (_mutex);
 
        /* Emit the current list of servers */
@@ -206,7 +202,7 @@ ServerFinder::connect (boost::function<void (ServerDescription)> fn)
                fn (*i);
        }
 
-       ServerFound.connect (fn);
+       return ServerFound.connect (fn);
 }
 
 ServerFinder*
index c0f1feb66e1d329167e55007ec8bdf4f6ac09521..3fab6864a332ef43b3b62a59bf2ccab75d49aae6 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
 class ServerFinder : public ExceptionStore
 {
 public:
-       void connect (boost::function<void (ServerDescription)>);
+       boost::signals2::connection connect (boost::function<void (ServerDescription)>);
 
        static ServerFinder* instance ();
        static void drop ();
@@ -32,6 +32,10 @@ public:
                _disabled = true;
        }
 
+       bool disabled () const {
+               return _disabled;
+       }
+
 private:
        ServerFinder ();
        ~ServerFinder ();
index f1d832d869d80ae7b3d514c8055fbce1f22f249f..7a7b4674cab0de3599ac9c4b689ebf09a62f9e67 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -114,7 +114,7 @@ AudioPanel::AudioPanel (ContentPanel* p)
        _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,  boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
        _processor->Bind             (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&AudioPanel::processor_changed, this));
 
-       _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
+       _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
 }
 
 
index 8003a5bd7f86121c376bb152e4e3899162781bdb..a5bfef4ca918ffc23425d33f52da15901c6f0f99 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -55,4 +55,6 @@ private:
        AudioMappingView* _mapping;
        wxStaticText* _description;
        AudioDialog* _audio_dialog;
+
+       boost::signals2::scoped_connection _mapping_connection;
 };
index 368a94636a4515b0b4724abb7ae638ec6b2b7675..c79c21dd1f0be29bc2c25fdc74abe5cfdc2ec37c 100644 (file)
@@ -362,7 +362,7 @@ public:
                _issuer->SetValue (std_to_wx (config->dcp_issuer ()));
                _issuer->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DefaultsPage::issuer_changed, this));
 
-               config->Changed.connect (boost::bind (&DefaultsPage::config_changed, this));
+               _config_connection = config->Changed.connect (boost::bind (&DefaultsPage::config_changed, this));
 
                return panel;
        }
@@ -430,6 +430,8 @@ private:
        wxChoice* _container;
        wxChoice* _dcp_content_type;
        wxTextCtrl* _issuer;
+
+       boost::signals2::scoped_connection _config_connection;
 };
 
 class EncodingServersPage : public wxPreferencesPage, public Page
index 3fa8e120a8cff1d41284529cf4cc38d2aa52989c..500a168f5d990eddb3d46311d43954e31e279bdc 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent)
        _preset_check->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentColourConversionDialog::preset_check_clicked, this));
        _preset_choice->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ContentColourConversionDialog::preset_choice_changed, this));
 
-       _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
+       _editor_connection = _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
 
        vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
        for (vector<PresetColourConversion>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
index e6069f117d583c6df33734087c0c0e00fa1f0a96..57fd5f1e544fdeec750e43364bef006b934b1fc2 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -38,4 +38,6 @@ private:
        wxChoice* _preset_choice;
        ColourConversionEditor* _editor;
        bool _setting;
+
+       boost::signals2::scoped_connection _editor_connection;
 };
index 3bdaf259110bf0e0fdf9b204c5059f86ace3d54d..749337b7518674c03b35ac2451272ebd84c26e12 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -209,7 +209,7 @@ ContentMenu::find_missing ()
 
        shared_ptr<Job> j (new ExamineContentJob (film, content));
        
-       j->Finished.connect (
+       _job_connection = j->Finished.connect (
                bind (
                        &ContentMenu::maybe_found_missing,
                        this,
index cd51e86f1a9fb21b14aa146d62287cca611b9a7e..996091f0cf59883a548ddb6c1f508d653e939aee 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -55,6 +55,8 @@ private:
        wxMenuItem* _re_examine;
        wxMenuItem* _kdm;
        wxMenuItem* _remove;
+
+       boost::signals2::scoped_connection _job_connection;
 };
 
 #endif
index b5d5c6971dd819972b9e4a583291b109a05491b1..406bcbf0f712892672d823a7fac4b0744dc8bcea 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -48,8 +48,8 @@ HintsDialog::HintsDialog (wxWindow* parent, boost::weak_ptr<Film> f)
 
        boost::shared_ptr<Film> film = _film.lock ();
        if (film) {
-               film->Changed.connect (boost::bind (&HintsDialog::film_changed, this));
-               film->ContentChanged.connect (boost::bind (&HintsDialog::film_changed, this));
+               _film_changed_connection = film->Changed.connect (boost::bind (&HintsDialog::film_changed, this));
+               _film_content_changed_connection = film->ContentChanged.connect (boost::bind (&HintsDialog::film_changed, this));
        }
 
        film_changed ();
index 810791453522472cb99ac0a084e970a2ec0b84bc..88b2fa1ba6617fcffae5573ece72110fbbfac47a 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -33,4 +33,7 @@ private:
        
        boost::weak_ptr<Film> _film;
        wxRichTextCtrl* _text;
+
+       boost::signals2::scoped_connection _film_changed_connection;
+       boost::signals2::scoped_connection _film_content_changed_connection;
 };
index 3593d2357be4d6ffc5160c02a31ffb6a1000436a..ec58607af6eed724489d4d1b18fbad6947762543 100644 (file)
@@ -79,8 +79,8 @@ public:
                table->Insert (n, _details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
                ++n;
        
-               job->Progress.connect (boost::bind (&JobRecord::progress, this));
-               job->Finished.connect (boost::bind (&JobRecord::finished, this));
+               _progress_connection = job->Progress.connect (boost::bind (&JobRecord::progress, this));
+               _finished_connection = job->Finished.connect (boost::bind (&JobRecord::finished, this));
        
                table->Layout ();
                panel->FitInside ();
@@ -181,6 +181,9 @@ private:
        wxButton* _pause;
        wxButton* _details;
        std::string _last_name;
+
+       boost::signals2::scoped_connection _progress_connection;
+       boost::signals2::scoped_connection _finished_connection;
 };
 
 /** Must be called in the GUI thread */
index 27fc75b1b39c649fd76b9890d1758e374f7af858..d1627edad33e7b1b3b3e6336bd3bf9942a325a7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@ PropertiesDialog::PropertiesDialog (wxWindow* parent, shared_ptr<Film> film)
 
        add (_("Frames already encoded"), true);
        _encoded = add (new ThreadedStaticText (this, _("counting..."), boost::bind (&PropertiesDialog::frames_already_encoded, this)));
-       _encoded->Finished.connect (boost::bind (&PropertiesDialog::layout, this));
+       _encoded_connection = _encoded->Finished.connect (boost::bind (&PropertiesDialog::layout, this));
        _frames->SetLabel (std_to_wx (lexical_cast<string> (_film->length().frames (_film->video_frame_rate ()))));
        double const disk = double (_film->required_disk_space()) / 1073741824.0f;
        SafeStringStream s;
index aeb8927b254458db68138dd4bbabe13d22e5e7b2..fe814f7abf341341a7ff3480f36a9f5085b730c4 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -35,5 +35,7 @@ private:
        wxStaticText* _frames;
        wxStaticText* _disk;
        ThreadedStaticText* _encoded;
+
+       boost::signals2::scoped_connection _encoded_connection;
 };
 
index be69a14ed47a4df5900880f3a9f20205bebf76d8..299ce2f20aee0c2e339515a7049655994afca96c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -61,7 +61,7 @@ ServersListDialog::ServersListDialog (wxWindow* parent)
        s->Layout ();
        s->SetSizeHints (this);
        
-       ServerFinder::instance()->connect (boost::bind (&ServersListDialog::server_found, this, _1));
+       _server_finder_connection = ServerFinder::instance()->connect (boost::bind (&ServersListDialog::server_found, this, _1));
 }
 
 void
index 27a3c55cb0d302ccf6b12b169bb74c657f1998ae..3804d2a7e17f9f3ddecad977759333c3597e655d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -31,4 +31,6 @@ private:
 
        std::list<ServerDescription> _servers;
        wxListCtrl* _list;
+
+       boost::signals2::scoped_connection _server_finder_connection;
 };