diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-10-26 23:39:38 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-10-27 00:48:41 +0100 |
| commit | 27cac69d4f8fd37f7003cee769adbe5d687c5f66 (patch) | |
| tree | c387d6dc6419be4173493da18551de3c899a8ec2 | |
| parent | 249ac581101203101d15cf581c9b54d857cee449 (diff) | |
Use new signal handling for Content.
| -rw-r--r-- | src/lib/content.cc | 6 | ||||
| -rw-r--r-- | src/lib/content.h | 5 | ||||
| -rw-r--r-- | src/lib/playlist.cc | 5 | ||||
| -rw-r--r-- | src/lib/playlist.h | 3 | ||||
| -rw-r--r-- | src/wx/content_widget.h | 11 | ||||
| -rw-r--r-- | src/wx/subtitle_appearance_dialog.cc | 2 | ||||
| -rw-r--r-- | src/wx/subtitle_appearance_dialog.h | 5 | ||||
| -rw-r--r-- | src/wx/timeline_content_view.cc | 2 | ||||
| -rw-r--r-- | src/wx/timeline_content_view.h | 6 |
9 files changed, 23 insertions, 22 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc index ac87c6e79..157a17118 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -191,11 +191,7 @@ void Content::signal_change(ChangeType c, int p) { try { - if (c == ChangeType::PENDING || c == ChangeType::CANCELLED) { - Change(c, p, _change_signals_frequent); - } else { - emit(boost::bind(boost::ref(Change), c, p, _change_signals_frequent)); - } + Change(c, p, _change_signals_frequent); } catch (std::bad_weak_ptr &) { /* This must be during construction; never mind */ } diff --git a/src/lib/content.h b/src/lib/content.h index d84505b72..3946f8b1e 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -31,12 +31,12 @@ #include "change_signaller.h" #include "dcpomatic_time.h" #include "path_behaviour.h" +#include "signal.h" #include "signaller.h" #include "user_property.h" #include "text_type.h" #include <libcxml/cxml.h> #include <boost/filesystem.hpp> -#include <boost/signals2.hpp> #include <boost/thread/mutex.hpp> @@ -218,8 +218,7 @@ public: bool has_mapped_audio() const; - /* ChangeType::PENDING and ChangeType::CANCELLED may be emitted from any thread; ChangeType::DONE always from GUI thread */ - boost::signals2::signal<void (ChangeType, int, bool)> Change; + Signal<void (ChangeType, int, bool)> Change; std::shared_ptr<VideoContent> video; std::shared_ptr<AudioContent> audio; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 8c60a5458..a91af4825 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -88,6 +88,7 @@ Playlist::~Playlist() } +/** Could be called from any thread */ void Playlist::content_change(weak_ptr<const Film> weak_film, ChangeType type, int property, bool frequent) { @@ -140,6 +141,8 @@ Playlist::content_change(weak_ptr<const Film> weak_film, ChangeType type, int pr void Playlist::maybe_sequence(shared_ptr<const Film> film) { + boost::mutex::scoped_lock lm(_mutex); + if (!_sequence || _sequencing) { return; } @@ -516,7 +519,7 @@ Playlist::reconnect(shared_ptr<const Film> film) disconnect(); for (auto i: _content) { - _content_connections.push_back(i->Change.connect(boost::bind(&Playlist::content_change, this, film, _1, _2, _3))); + _content_connections.push_back(i->Change.connect_same_thread(boost::bind(&Playlist::content_change, this, film, _1, _2, _3))); } } diff --git a/src/lib/playlist.h b/src/lib/playlist.h index 0d38cbf67..ca4a80bbf 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -27,6 +27,7 @@ #include "dcpomatic_time.h" #include "frame_rate_change.h" #include "path_behaviour.h" +#include "signal.h" #include "types.h" #include <libcxml/cxml.h> #include <boost/signals2.hpp> @@ -99,7 +100,7 @@ private: ContentList _content; bool _sequence = true; bool _sequencing = false; - std::list<boost::signals2::connection> _content_connections; + std::list<Connection> _content_connections; }; diff --git a/src/wx/content_widget.h b/src/wx/content_widget.h index 3c736f2a9..6bae555ce 100644 --- a/src/wx/content_widget.h +++ b/src/wx/content_widget.h @@ -30,6 +30,7 @@ #include "wx_util.h" #include "lib/content.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/gbsizer.h> @@ -49,7 +50,7 @@ LIBDCP_ENABLE_WARNINGS * @param V Data type of state as used by the view. */ template <class S, class T, typename U, typename V> -class ContentWidget +class ContentWidget : public Trackable { public: /** @param parent Parent window. @@ -104,7 +105,7 @@ public: /** Set the content that this control is working on (i.e. the selected content) */ void set_content (List content) { - for (typename std::list<boost::signals2::connection>::iterator i = _connections.begin(); i != _connections.end(); ++i) { + for (typename std::list<Connection>::iterator i = _connections.begin(); i != _connections.end(); ++i) { i->disconnect (); } @@ -118,9 +119,9 @@ public: for (typename List::iterator i = _content.begin(); i != _content.end(); ++i) { #if BOOST_VERSION >= 106100 - _connections.push_back((*i)->Change.connect(boost::bind(&ContentWidget::model_changed, this, boost::placeholders::_1, boost::placeholders::_2))); + _connections.push_back((*i)->Change.connect_ui_thread(this, boost::bind(&ContentWidget::model_changed, this, boost::placeholders::_1, boost::placeholders::_2))); #else - _connections.push_back((*i)->Change.connect(boost::bind(&ContentWidget::model_changed, this, _1, _2))); + _connections.push_back((*i)->Change.connect_ui_thread(this, boost::bind(&ContentWidget::model_changed, this, _1, _2))); #endif } } @@ -229,7 +230,7 @@ private: std::function<void ()> _view_changed; std::function<U (V)> _view_to_model; std::function<V (U)> _model_to_view; - std::list<boost::signals2::connection> _connections; + std::list<Connection> _connections; bool _ignore_model_changes; }; diff --git a/src/wx/subtitle_appearance_dialog.cc b/src/wx/subtitle_appearance_dialog.cc index 44e7b88d8..302e41980 100644 --- a/src/wx/subtitle_appearance_dialog.cc +++ b/src/wx/subtitle_appearance_dialog.cc @@ -210,7 +210,7 @@ SubtitleAppearanceDialog::SubtitleAppearanceDialog (wxWindow* parent, shared_ptr _force_fade_in->bind(&SubtitleAppearanceDialog::setup_sensitivity, this); _force_fade_out->bind(&SubtitleAppearanceDialog::setup_sensitivity, this); _effect->Bind (wxEVT_CHOICE, bind (&SubtitleAppearanceDialog::setup_sensitivity, this)); - _content_connection = _content->Change.connect (bind (&SubtitleAppearanceDialog::content_change, this, _1)); + _content_connection = _content->Change.connect_ui_thread(this, bind(&SubtitleAppearanceDialog::content_change, this, _1)); setup_sensitivity (); } diff --git a/src/wx/subtitle_appearance_dialog.h b/src/wx/subtitle_appearance_dialog.h index cef264590..db084533c 100644 --- a/src/wx/subtitle_appearance_dialog.h +++ b/src/wx/subtitle_appearance_dialog.h @@ -22,6 +22,7 @@ #include "timecode.h" #include "lib/change_signaller.h" #include "lib/rgba.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> @@ -41,7 +42,7 @@ class wxRadioButton; class wxWidget; -class SubtitleAppearanceDialog : public wxDialog +class SubtitleAppearanceDialog : public wxDialog, public Trackable { public: SubtitleAppearanceDialog (wxWindow* parent, std::shared_ptr<const Film> film, std::shared_ptr<Content> content, std::shared_ptr<TextContent> caption); @@ -80,7 +81,7 @@ private: std::shared_ptr<TextContent> _text; std::shared_ptr<FFmpegSubtitleStream> _stream; - boost::signals2::scoped_connection _content_connection; + ScopedConnection _content_connection; boost::signals2::scoped_connection _job_manager_connection; std::weak_ptr<Job> _job; diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 69a675c42..9438fd4b9 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -42,7 +42,7 @@ TimelineContentView::TimelineContentView(ContentTimeline& tl, shared_ptr<Content : ContentTimelineView(tl) , _content (c) { - _content_connection = c->Change.connect (bind (&TimelineContentView::content_change, this, _1, _3)); + _content_connection = c->Change.connect_ui_thread(this, bind(&TimelineContentView::content_change, this, _1, _3)); } diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index 7b206d30f..9cd21845a 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -25,11 +25,11 @@ #include "content_timeline_view.h" #include "lib/change_signaller.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class Content; @@ -37,7 +37,7 @@ class Content; /** @class TimelineContentView * @brief Parent class for views of pieces of content. */ -class TimelineContentView : public ContentTimelineView +class TimelineContentView : public ContentTimelineView, public Trackable { public: TimelineContentView(ContentTimeline& tl, std::shared_ptr<Content> c); @@ -68,7 +68,7 @@ private: boost::optional<int> _track; bool _selected = false; - boost::signals2::scoped_connection _content_connection; + ScopedConnection _content_connection; }; |
