summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-03-16 22:25:57 +0000
committerCarl Hetherington <cth@carlh.net>2015-03-16 22:25:57 +0000
commit1b0b9e4b951e305d47bb011fc4e198472bb3fecf (patch)
tree715db098b0a716a0ee3d46aa060fecadcffc1766 /src
parentc416bee48d5a5829077c844c5f2b802bf13ab4cd (diff)
Hand-apply 33b76b675d747fd828aba91d9d857227cb8a8244 from master; make sure signals are disconnected in the right places.
Diffstat (limited to 'src')
-rw-r--r--src/lib/encoder.cc4
-rw-r--r--src/lib/encoder.h2
-rw-r--r--src/lib/film.cc17
-rw-r--r--src/lib/film.h5
-rw-r--r--src/lib/server_finder.cc8
-rw-r--r--src/lib/server_finder.h8
-rw-r--r--src/wx/audio_panel.cc4
-rw-r--r--src/wx/audio_panel.h4
-rw-r--r--src/wx/config_dialog.cc4
-rw-r--r--src/wx/content_colour_conversion_dialog.cc4
-rw-r--r--src/wx/content_colour_conversion_dialog.h4
-rw-r--r--src/wx/content_menu.cc4
-rw-r--r--src/wx/content_menu.h4
-rw-r--r--src/wx/hints_dialog.cc6
-rw-r--r--src/wx/hints_dialog.h5
-rw-r--r--src/wx/job_manager_view.cc7
-rw-r--r--src/wx/properties_dialog.cc4
-rw-r--r--src/wx/properties_dialog.h4
-rw-r--r--src/wx/servers_list_dialog.cc4
-rw-r--r--src/wx/servers_list_dialog.h4
20 files changed, 72 insertions, 34 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 6b520571a..2a6026879 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -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
diff --git a/src/lib/encoder.h b/src/lib/encoder.h
index 694c9bf1f..a4fe55874 100644
--- a/src/lib/encoder.h
+++ b/src/lib/encoder.h
@@ -114,6 +114,8 @@ private:
boost::shared_ptr<Writer> _writer;
Waker _waker;
+
+ boost::signals2::scoped_connection _server_found_connection;
};
#endif
diff --git a/src/lib/film.cc b/src/lib/film.cc
index c695a7d4b..0b48bf7b1 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -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);
}
diff --git a/src/lib/film.h b/src/lib/film.h
index 2de065159..c3ab9f2ff 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -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;
};
diff --git a/src/lib/server_finder.cc b/src/lib/server_finder.cc
index bef00702f..d62531d9f 100644
--- a/src/lib/server_finder.cc
+++ b/src/lib/server_finder.cc
@@ -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*
diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h
index c0f1feb66..3fab6864a 100644
--- a/src/lib/server_finder.h
+++ b/src/lib/server_finder.h
@@ -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 ();
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
index f1d832d86..7a7b4674c 100644
--- a/src/wx/audio_panel.cc
+++ b/src/wx/audio_panel.cc
@@ -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));
}
diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h
index 8003a5bd7..a5bfef4ca 100644
--- a/src/wx/audio_panel.h
+++ b/src/wx/audio_panel.h
@@ -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;
};
diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc
index 368a94636..c79c21dd1 100644
--- a/src/wx/config_dialog.cc
+++ b/src/wx/config_dialog.cc
@@ -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
diff --git a/src/wx/content_colour_conversion_dialog.cc b/src/wx/content_colour_conversion_dialog.cc
index 3fa8e120a..500a168f5 100644
--- a/src/wx/content_colour_conversion_dialog.cc
+++ b/src/wx/content_colour_conversion_dialog.cc
@@ -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) {
diff --git a/src/wx/content_colour_conversion_dialog.h b/src/wx/content_colour_conversion_dialog.h
index e6069f117..57fd5f1e5 100644
--- a/src/wx/content_colour_conversion_dialog.h
+++ b/src/wx/content_colour_conversion_dialog.h
@@ -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;
};
diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc
index 3bdaf2591..749337b75 100644
--- a/src/wx/content_menu.cc
+++ b/src/wx/content_menu.cc
@@ -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,
diff --git a/src/wx/content_menu.h b/src/wx/content_menu.h
index cd51e86f1..996091f0c 100644
--- a/src/wx/content_menu.h
+++ b/src/wx/content_menu.h
@@ -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
diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc
index b5d5c6971..406bcbf0f 100644
--- a/src/wx/hints_dialog.cc
+++ b/src/wx/hints_dialog.cc
@@ -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 ();
diff --git a/src/wx/hints_dialog.h b/src/wx/hints_dialog.h
index 810791453..88b2fa1ba 100644
--- a/src/wx/hints_dialog.h
+++ b/src/wx/hints_dialog.h
@@ -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;
};
diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc
index 3593d2357..ec58607af 100644
--- a/src/wx/job_manager_view.cc
+++ b/src/wx/job_manager_view.cc
@@ -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 */
diff --git a/src/wx/properties_dialog.cc b/src/wx/properties_dialog.cc
index 27fc75b1b..d1627edad 100644
--- a/src/wx/properties_dialog.cc
+++ b/src/wx/properties_dialog.cc
@@ -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;
diff --git a/src/wx/properties_dialog.h b/src/wx/properties_dialog.h
index aeb8927b2..fe814f7ab 100644
--- a/src/wx/properties_dialog.h
+++ b/src/wx/properties_dialog.h
@@ -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;
};
diff --git a/src/wx/servers_list_dialog.cc b/src/wx/servers_list_dialog.cc
index be69a14ed..299ce2f20 100644
--- a/src/wx/servers_list_dialog.cc
+++ b/src/wx/servers_list_dialog.cc
@@ -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
diff --git a/src/wx/servers_list_dialog.h b/src/wx/servers_list_dialog.h
index 27a3c55cb..3804d2a7e 100644
--- a/src/wx/servers_list_dialog.h
+++ b/src/wx/servers_list_dialog.h
@@ -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;
};