diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-06-12 00:27:33 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-06-14 23:43:13 +0200 |
| commit | a12a943c99ba4aba122f91c93b078d2e87146b32 (patch) | |
| tree | 93e149bc2d6f9c2ff98aa05c5d51e096dd0c6598 /src | |
| parent | 6d2d4973ccd5d4c78414d28988a74dfa7287f001 (diff) | |
Use a new UISignal which checks thread safety slightly.3052-hang
This adds a wrapper around signals2::signal which checks that emission
happens from the GUI thread, for signals whose handlers must be called
in the UI thread. I'm not sure how helpful it really is but maybe it
catches some bad situations.
Diffstat (limited to 'src')
47 files changed, 189 insertions, 98 deletions
diff --git a/src/lib/config.h b/src/lib/config.h index c90790ebc..0fbc3b7e9 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -31,6 +31,7 @@ #include "enum_indexed_vector.h" #include "export_config.h" #include "rough_duration.h" +#include "signal.h" #include "state.h" #include "video_encoding.h" #include <dcp/name_format.h> @@ -1250,7 +1251,7 @@ public: void changed(Property p = OTHER); - boost::signals2::signal<void (Property)> Changed; + UISignal<void (Property)> Changed; /** Emitted if read() failed on an existing Config file. There is nothing a listener can do about it: this is just for information. */ diff --git a/src/lib/encode_server_finder.cc b/src/lib/encode_server_finder.cc index 1a0329dd7..1bee8eb52 100644 --- a/src/lib/encode_server_finder.cc +++ b/src/lib/encode_server_finder.cc @@ -169,7 +169,7 @@ try } if (removed) { - emit (boost::bind(boost::ref(ServersListChanged))); + ServersListChanged.emit_ui(this); } boost::mutex::scoped_lock lm (_search_condition_mutex); @@ -269,7 +269,7 @@ EncodeServerFinder::handle_accept (boost::system::error_code ec) } if (changed) { - emit (boost::bind(boost::ref (ServersListChanged))); + ServersListChanged.emit_ui(this); } start_accept (); diff --git a/src/lib/encode_server_finder.h b/src/lib/encode_server_finder.h index 722786b77..d5db0234d 100644 --- a/src/lib/encode_server_finder.h +++ b/src/lib/encode_server_finder.h @@ -27,6 +27,7 @@ #include "config.h" #include "encode_server_description.h" #include "exception_store.h" +#include "signal.h" #include "signaller.h" #include <boost/signals2.hpp> #include <boost/thread/condition.hpp> @@ -53,7 +54,7 @@ public: std::list<EncodeServerDescription> servers () const; /** Emitted whenever the list of servers changes */ - boost::signals2::signal<void ()> ServersListChanged; + UISignal<void ()> ServersListChanged; private: EncodeServerFinder (); diff --git a/src/lib/film.cc b/src/lib/film.cc index 09378696e..d7cb05930 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1310,7 +1310,7 @@ Film::signal_change(ChangeType type, FilmProperty p) if (type == ChangeType::DONE) { set_dirty(true); - emit(boost::bind(boost::ref(Change), type, p)); + Change.emit_ui(this, type, p); if (p == FilmProperty::VIDEO_FRAME_RATE || p == FilmProperty::SEQUENCE) { /* We want to call Playlist::maybe_sequence but this must happen after the @@ -1577,7 +1577,7 @@ Film::playlist_content_change(ChangeType type, weak_ptr<Content> c, int p, bool } if (type == ChangeType::DONE) { - emit(boost::bind(boost::ref(ContentChange), type, c, p, frequent)); + ContentChange.emit_ui(this, type, c, p, frequent); if (!frequent) { check_settings_consistency(); } @@ -2325,7 +2325,7 @@ Film::set_dirty(bool dirty) auto const changed = dirty != _dirty; _dirty = dirty; if (changed) { - emit(boost::bind(boost::ref(DirtyChange), _dirty)); + DirtyChange.emit_ui(this, _dirty); } } diff --git a/src/lib/film.h b/src/lib/film.h index c14b0f4fa..9f066e628 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -38,6 +38,7 @@ #include "named_channel.h" #include "remembered_asset.h" #include "resolution.h" +#include "signal.h" #include "signaller.h" #include "territory_type.h" #include "transcode_job.h" @@ -440,20 +441,20 @@ public: boost::filesystem::path info_file(dcpomatic::DCPTimePeriod p) const; /** Emitted when some property has of the Film is about to change or has changed */ - mutable boost::signals2::signal<void (ChangeType, FilmProperty)> Change; + mutable UISignal<void (ChangeType, FilmProperty)> Change; /** Emitted when some property of our content has changed */ - mutable boost::signals2::signal<void (ChangeType, std::weak_ptr<Content>, int, bool)> ContentChange; + mutable UISignal<void (ChangeType, std::weak_ptr<Content>, int, bool)> ContentChange; /** Emitted when the film's length might have changed; this is not like a normal property as its value is derived from the playlist, so it has its own signal. */ - mutable boost::signals2::signal<void ()> LengthChange; + mutable UISignal<void ()> LengthChange; - boost::signals2::signal<void (bool)> DirtyChange; + UISignal<void (bool)> DirtyChange; /** Emitted when we have something important to tell the user */ - boost::signals2::signal<void (std::string)> Message; + UISignal<void (std::string)> Message; /** Current version number of the state file */ static int const current_state_version; diff --git a/src/lib/hints.cc b/src/lib/hints.cc index 17aa16d47..5e9756b2b 100644 --- a/src/lib/hints.cc +++ b/src/lib/hints.cc @@ -411,11 +411,11 @@ Hints::scan_content(shared_ptr<const Film> film) } if (check_loudness_done && have_text) { - emit(boost::bind(boost::ref(Progress), _("Examining subtitles and closed captions"))); + Progress.emit_ui(this, _("Examining subtitles and closed captions")); } else if (!check_loudness_done && !have_text) { - emit(boost::bind(boost::ref(Progress), _("Examining audio"))); + Progress.emit_ui(this, _("Examining audio")); } else { - emit(boost::bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions"))); + Progress.emit_ui(this, _("Examining audio, subtitles and closed captions")); } auto player = make_shared<Player>(film, Image::Alignment::COMPACT, false); @@ -442,7 +442,7 @@ Hints::scan_content(shared_ptr<const Film> film) if (_stop) { return; } - emit(boost::bind(boost::ref(Pulse))); + Pulse.emit_ui(this); last_pulse = now; } } @@ -536,7 +536,7 @@ try } dcp::filesystem::remove_all(dcp_dir); - emit(boost::bind(boost::ref(Finished))); + Finished.emit_ui(this); } catch (boost::thread_interrupted) { @@ -545,14 +545,14 @@ catch (boost::thread_interrupted) catch (...) { store_current(); - emit(boost::bind(boost::ref(Finished))); + Finished.emit_ui(this); } void Hints::hint(string h) { - emit(boost::bind(boost::ref(Hint), h)); + Hint.emit_ui(this, h); } diff --git a/src/lib/hints.h b/src/lib/hints.h index 49fd32ea9..56a5eb787 100644 --- a/src/lib/hints.h +++ b/src/lib/hints.h @@ -23,11 +23,11 @@ #include "dcp_text_track.h" #include "dcpomatic_time.h" #include "player_text.h" +#include "signal.h" #include "signaller.h" #include "text_type.h" #include "weak_film.h" #include <boost/atomic.hpp> -#include <boost/signals2.hpp> #include <string> #include <vector> @@ -44,10 +44,10 @@ public: void start(); - boost::signals2::signal<void (std::string)> Hint; - boost::signals2::signal<void (std::string)> Progress; - boost::signals2::signal<void (void)> Pulse; - boost::signals2::signal<void (void)> Finished; + UISignal<void (std::string)> Hint; + UISignal<void (std::string)> Progress; + UISignal<void ()> Pulse; + UISignal<void ()> Finished; /* For tests only */ void join(); diff --git a/src/lib/job.cc b/src/lib/job.cc index ee6ad4e70..9f28c2bc2 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -375,7 +375,7 @@ Job::set_state (State s) if (finished) { auto const result = state_to_result(s); - emit(boost::bind(boost::ref(Finished), result)); + Finished.emit_ui(this, result); FinishedImmediate(result); } } @@ -419,7 +419,7 @@ Job::check_for_interruption_or_pause () boost::mutex::scoped_lock lm (_state_mutex); while (_state == PAUSED_BY_USER || _state == PAUSED_BY_PRIORITY) { - emit (boost::bind (boost::ref (Progress))); + Progress.emit_ui(this); _pause_changed.wait (lm); } } @@ -475,7 +475,7 @@ Job::set_progress_common (optional<float> p) _progress = p; } - emit (boost::bind (boost::ref (Progress))); + Progress.emit_ui(this); } diff --git a/src/lib/job.h b/src/lib/job.h index 9b5fdfa6e..a80d66cda 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -28,6 +28,7 @@ #define DCPOMATIC_JOB_H +#include "signal.h" #include "signaller.h" #include <boost/atomic.hpp> #include <boost/signals2.hpp> @@ -108,9 +109,9 @@ public: void set_rate_limit_progress(bool rate_limit); - boost::signals2::signal<void()> Progress; + UISignal<void()> Progress; /** Emitted from the UI thread when the job is finished */ - boost::signals2::signal<void (Result)> Finished; + UISignal<void (Result)> Finished; /** Emitted from the job thread when the job is finished */ boost::signals2::signal<void (Result)> FinishedImmediate; diff --git a/src/lib/job_manager.cc b/src/lib/job_manager.cc index c429dab6e..735b8e797 100644 --- a/src/lib/job_manager.cc +++ b/src/lib/job_manager.cc @@ -93,7 +93,7 @@ JobManager::add(shared_ptr<Job> j) _schedule_condition.notify_all(); } - emit(boost::bind(boost::ref(JobAdded), weak_ptr<Job>(j))); + JobAdded.emit_ui(this, weak_ptr<Job>(j)); return j; } @@ -110,7 +110,7 @@ JobManager::add_after(shared_ptr<Job> after, shared_ptr<Job> j) _schedule_condition.notify_all(); } - emit(boost::bind(boost::ref(JobAdded), weak_ptr<Job>(j))); + JobAdded.emit_ui(this, weak_ptr<Job>(j)); return j; } @@ -178,7 +178,7 @@ JobManager::scheduler() i->resume(); } auto last = _last_active_job.lock(); - emit(boost::bind(boost::ref(ActiveJobsChanged), last ? last->json_name() : std::string{}, i->json_name())); + ActiveJobsChanged.emit_ui(this, last ? last->json_name() : std::string{}, i->json_name()); _last_active_job = i; have_running = true; } else if (!have_running && i->running()) { @@ -197,7 +197,7 @@ JobManager::job_finished() { boost::mutex::scoped_lock lm(_mutex); auto job = _last_active_job.lock(); - emit(boost::bind(boost::ref(ActiveJobsChanged), job ? job->json_name() : string{}, optional<string>())); + ActiveJobsChanged.emit_ui(this, job ? job->json_name() : string{}, optional<string>()); _last_active_job = {}; } @@ -257,7 +257,7 @@ JobManager::analyse_audio( _schedule_condition.notify_all(); } - emit(boost::bind(boost::ref(JobAdded), weak_ptr<Job>(job))); + JobAdded.emit_ui(this, weak_ptr<Job>(job)); } @@ -292,7 +292,7 @@ JobManager::analyse_subtitles( _schedule_condition.notify_all(); } - emit(boost::bind(boost::ref(JobAdded), weak_ptr<Job>(job))); + JobAdded.emit_ui(this, weak_ptr<Job>(job)); } @@ -309,7 +309,7 @@ JobManager::increase_priority (shared_ptr<Job> job) } _schedule_condition.notify_all(); - emit(boost::bind(boost::ref(JobsReordered))); + JobsReordered.emit_ui(this); } @@ -326,7 +326,7 @@ JobManager::decrease_priority(shared_ptr<Job> job) } _schedule_condition.notify_all(); - emit(boost::bind(boost::ref(JobsReordered))); + JobsReordered.emit_ui(this); } diff --git a/src/lib/job_manager.h b/src/lib/job_manager.h index 248639782..f7981df41 100644 --- a/src/lib/job_manager.h +++ b/src/lib/job_manager.h @@ -25,6 +25,7 @@ #include "job.h" +#include "signal.h" #include "signaller.h" #include <boost/thread/mutex.hpp> #include <boost/thread.hpp> @@ -86,9 +87,9 @@ public: void cancel_all_jobs(); - boost::signals2::signal<void (std::weak_ptr<Job>)> JobAdded; - boost::signals2::signal<void ()> JobsReordered; - boost::signals2::signal<void (boost::optional<std::string>, boost::optional<std::string>)> ActiveJobsChanged; + UISignal<void (std::weak_ptr<Job>)> JobAdded; + UISignal<void ()> JobsReordered; + UISignal<void (boost::optional<std::string>, boost::optional<std::string>)> ActiveJobsChanged; static JobManager* instance(); static void drop(); diff --git a/src/lib/player.h b/src/lib/player.h index 9076ac242..bd8fc1c52 100644 --- a/src/lib/player.h +++ b/src/lib/player.h @@ -39,6 +39,7 @@ #include "player_text.h" #include "position_image.h" #include "shuffler.h" +#include "signal.h" #include <boost/atomic.hpp> #include <list> @@ -119,7 +120,7 @@ public: * Second parameter is the property. * Third parameter is true if these signals are currently likely to be frequent. */ - boost::signals2::signal<void (ChangeType, int, bool)> Change; + UISignal<void (ChangeType, int, bool)> Change; /** Emitted when a video frame is ready. These emissions happen in the correct order. */ boost::signals2::signal<void (std::shared_ptr<PlayerVideo>, dcpomatic::DCPTime)> Video; diff --git a/src/lib/signal.h b/src/lib/signal.h new file mode 100644 index 000000000..03b440e79 --- /dev/null +++ b/src/lib/signal.h @@ -0,0 +1,70 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net> + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#ifndef DCPOMATIC_SIGNAL_H +#define DCPOMATIC_SIGNAL_H + + +#include "signaller.h" +#include "util.h" +#include <boost/signals2.hpp> +#include <utility> + + +/** Wrapper for a boost::signals2::signal that asserts that emissions are made from the + * UI thead, so anything connected to it will be guaranteed to be called from there. + */ +template <typename T> +class UISignal +{ +public: + template <typename... Args> + void emit_ui(Signaller* signaller, Args&&... args) const + { + signaller->emit(boost::bind(boost::ref(_wrapped), std::forward<Args>(args)...)); + } + + template <typename... Args> + void emit(Args&&... args) const + { + ensure_ui_thread(); + _wrapped(std::forward<Args>(args)...); + } + + template <typename... Args> + boost::signals2::connection connect(Args&&... args) + { + return _wrapped.connect(std::forward<Args>(args)...); + } + + template <typename... Args> + void operator()(Args&&... args) const + { + emit(std::forward<Args>(args)...); + } + +private: + boost::signals2::signal<T> _wrapped; +}; + + +#endif + diff --git a/src/wx/audio_mapping_view.h b/src/wx/audio_mapping_view.h index 7fb3c0463..c38b8b725 100644 --- a/src/wx/audio_mapping_view.h +++ b/src/wx/audio_mapping_view.h @@ -26,11 +26,11 @@ #include "lib/audio_mapping.h" #include "lib/named_channel.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> /** @class AudioMappingView @@ -74,7 +74,7 @@ public: void set_input_groups (std::vector<Group> const & groups); - boost::signals2::signal<void (AudioMapping)> Changed; + UISignal<void (AudioMapping)> Changed; private: void map_values_changed (); diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h index f3d80b5e5..35d96b686 100644 --- a/src/wx/audio_plot.h +++ b/src/wx/audio_plot.h @@ -21,11 +21,11 @@ #include "lib/audio_analysis.h" #include "lib/constants.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> #include <vector> struct Metrics; @@ -45,7 +45,7 @@ public: wxColour colour (int n) const; - boost::signals2::signal<void (boost::optional<dcpomatic::DCPTime>, boost::optional<float>)> Cursor; + UISignal<void (boost::optional<dcpomatic::DCPTime>, boost::optional<float>)> Cursor; static const int max_smoothing; diff --git a/src/wx/auto_crop_dialog.h b/src/wx/auto_crop_dialog.h index 4ccd681ed..8e1eb6a0c 100644 --- a/src/wx/auto_crop_dialog.h +++ b/src/wx/auto_crop_dialog.h @@ -25,7 +25,7 @@ #include "table_dialog.h" #include "lib/crop.h" -#include <boost/signals2.hpp> +#include "lib/signal.h" class SpinCtrl; @@ -39,7 +39,7 @@ public: Crop get () const; void set (Crop crop); - boost::signals2::signal<void (Crop)> Changed; + UISignal<void (Crop)> Changed; private: SpinCtrl* _left; diff --git a/src/wx/colour_conversion_editor.h b/src/wx/colour_conversion_editor.h index de5ffb794..45256a1f8 100644 --- a/src/wx/colour_conversion_editor.h +++ b/src/wx/colour_conversion_editor.h @@ -23,11 +23,11 @@ #define DCPOMATIC_COLOUR_CONVERSION_EDITOR_H +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class ColourConversion; @@ -43,7 +43,7 @@ public: void set (ColourConversion); ColourConversion get () const; - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; private: void changed (); diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index f99d518a2..ad4d2a006 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -22,6 +22,7 @@ #include "content_menu.h" #include "lib/enum_indexed_vector.h" #include "lib/film_property.h" +#include "lib/signal.h" #include "lib/text_type.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -96,7 +97,7 @@ public: void add_dcp(boost::filesystem::path dcp); void add_folder(boost::filesystem::path folder); - boost::signals2::signal<void (void)> SelectionChanged; + UISignal<void (void)> SelectionChanged; private: void item_selected (); diff --git a/src/wx/dcp_timeline.cc b/src/wx/dcp_timeline.cc index a5b106c00..87947c110 100644 --- a/src/wx/dcp_timeline.cc +++ b/src/wx/dcp_timeline.cc @@ -33,6 +33,7 @@ #include "lib/constants.h" #include "lib/dcp_content.h" #include "lib/film.h" +#include "lib/signal.h" #include "lib/text_content.h" #include "lib/video_content.h" #include <dcp/scope_guard.h> @@ -121,7 +122,7 @@ public: return _view; } - boost::signals2::signal<void (int, dcpomatic::DCPTime)> Changed; + UISignal<void (int, dcpomatic::DCPTime)> Changed; private: void timecode_changed() { diff --git a/src/wx/dir_picker_ctrl.h b/src/wx/dir_picker_ctrl.h index fc5d5a755..b474dfd82 100644 --- a/src/wx/dir_picker_ctrl.h +++ b/src/wx/dir_picker_ctrl.h @@ -23,6 +23,7 @@ #define DCPOMATIC_DIR_PICKER_CTRL +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> @@ -41,7 +42,7 @@ public: wxString GetPath() const; void SetPath(wxString); - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; private: void browse_clicked(); diff --git a/src/wx/dkdm_output_panel.h b/src/wx/dkdm_output_panel.h index 31f621830..0114f3d56 100644 --- a/src/wx/dkdm_output_panel.h +++ b/src/wx/dkdm_output_panel.h @@ -22,6 +22,7 @@ #include "name_format_editor.h" #include "wx_util.h" #include "lib/kdm_with_metadata.h" +#include "lib/signal.h" #include <dcp/types.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -56,7 +57,7 @@ public: bool method_selected() const; - boost::signals2::signal<void ()> MethodChanged; + UISignal<void ()> MethodChanged; private: void method_changed(); diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index f1b74b193..5146fa0f6 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -201,7 +201,7 @@ public: _sizer->Layout (); } - boost::signals2::signal<void ()> SelectionChanged; + UISignal<void ()> SelectionChanged; private: diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h index 54d639ef5..0e17c2c81 100644 --- a/src/wx/film_editor.h +++ b/src/wx/film_editor.h @@ -51,7 +51,7 @@ public: void set_film (std::shared_ptr<Film>); void first_shown (); - boost::signals2::signal<void (void)> SelectionChanged; + UISignal<void (void)> SelectionChanged; /* Stuff for panels */ diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index 0397e4c91..9b397a1df 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -104,7 +104,7 @@ FilmViewer::FilmViewer(wxWindow* p) #endif _video_view->Sized.connect(boost::bind(&FilmViewer::video_view_sized, this)); - _video_view->TooManyDropped.connect(boost::bind(boost::ref(TooManyDropped))); + _video_view->TooManyDropped.connect([this]() { TooManyDropped(); }); set_film(shared_ptr<Film>()); @@ -866,7 +866,7 @@ void FilmViewer::image_changed(shared_ptr<PlayerVideo> pv) { _last_image = pv; - emit(boost::bind(boost::ref(ImageChanged))); + ImageChanged.emit_ui(this); } diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index 2a6239d7d..ad9b810db 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -25,6 +25,7 @@ #include "optimisation.h" +#include "signal.h" #include "video_view.h" #include "lib/change_signaller.h" #include "lib/config.h" @@ -156,16 +157,17 @@ public: Frame average_latency() const; /** The image we are viewing changed: call last_image() to get the image */ - boost::signals2::signal<void ()> ImageChanged; + UISignal<void ()> ImageChanged; std::shared_ptr<const PlayerVideo> last_image() const; - boost::signals2::signal<void ()> Started; - boost::signals2::signal<void ()> Stopped; + UISignal<void ()> Started; + UISignal<void ()> Stopped; /** While playing back we reached the end of the film (emitted from GUI thread) */ - boost::signals2::signal<void ()> Finished; + UISignal<void ()> Finished; /** Emitted from the GUI thread when a lot of frames are being dropped */ - boost::signals2::signal<void()> TooManyDropped; + UISignal<void()> TooManyDropped; + /* XXX: could be UISignal but this needs a return type and that is tricky in C++11 AFAICS */ boost::signals2::signal<bool ()> PlaybackPermitted; private: diff --git a/src/wx/filter_dialog.h b/src/wx/filter_dialog.h index aaa43c3e4..f5b724997 100644 --- a/src/wx/filter_dialog.h +++ b/src/wx/filter_dialog.h @@ -24,11 +24,11 @@ */ +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class Film; @@ -43,7 +43,7 @@ class FilterDialog : public wxDialog public: FilterDialog(wxWindow *, std::vector<Filter> const&); - boost::signals2::signal<void (std::vector<Filter>)> ActiveChanged; + UISignal<void (std::vector<Filter>)> ActiveChanged; private: void active_changed (); diff --git a/src/wx/focus_manager.h b/src/wx/focus_manager.h index ca4c4e384..91fbcd4fc 100644 --- a/src/wx/focus_manager.h +++ b/src/wx/focus_manager.h @@ -19,6 +19,7 @@ */ +#include "lib/signal.h" #include <boost/signals2.hpp> @@ -38,9 +39,9 @@ class FocusManager { public: /** emitted when any add()ed TextCtrl gets focus */ - boost::signals2::signal<void ()> SetFocus; + UISignal<void ()> SetFocus; /** emitted when any add()ed TextCtrl loses focus */ - boost::signals2::signal<void ()> KillFocus; + UISignal<void ()> KillFocus; void add(wxTextCtrl* c); diff --git a/src/wx/kdm_cpl_panel.h b/src/wx/kdm_cpl_panel.h index 91821d7a3..dd190be2b 100644 --- a/src/wx/kdm_cpl_panel.h +++ b/src/wx/kdm_cpl_panel.h @@ -19,6 +19,7 @@ */ +#include "lib/signal.h" #include "lib/types.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -36,7 +37,7 @@ public: boost::filesystem::path cpl () const; bool has_selected () const; - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; private: void update_cpl_choice (); diff --git a/src/wx/kdm_output_panel.h b/src/wx/kdm_output_panel.h index b555162dd..ddd474b0b 100644 --- a/src/wx/kdm_output_panel.h +++ b/src/wx/kdm_output_panel.h @@ -25,6 +25,7 @@ #include "wx_util.h" #include "lib/kdm_with_metadata.h" +#include "lib/signal.h" #include <dcp/types.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -73,7 +74,7 @@ public: void set_annotation_text(std::string text); std::string annotation_text() const; - boost::signals2::signal<void ()> MethodChanged; + UISignal<void ()> MethodChanged; protected: void create_destination_widgets(wxWindow* parent); diff --git a/src/wx/kdm_timing_panel.h b/src/wx/kdm_timing_panel.h index a6199534a..477d489d1 100644 --- a/src/wx/kdm_timing_panel.h +++ b/src/wx/kdm_timing_panel.h @@ -20,6 +20,7 @@ #include "wx_util.h" +#include "lib/signal.h" #include <dcp/utc_offset.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -49,7 +50,7 @@ public: */ void suggest_utc_offset(dcp::UTCOffset offset); - boost::signals2::signal<void ()> TimingChanged; + UISignal<void ()> TimingChanged; private: void changed () const; diff --git a/src/wx/language_subtag_panel.h b/src/wx/language_subtag_panel.h index 6f1b5fd01..5ebe397e4 100644 --- a/src/wx/language_subtag_panel.h +++ b/src/wx/language_subtag_panel.h @@ -20,6 +20,7 @@ #include "subtag_list_ctrl.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/srchctrl.h> @@ -39,8 +40,8 @@ public: void set(dcp::LanguageTag::SubtagType type, std::string search, boost::optional<dcp::LanguageTag::SubtagData> subtag = boost::optional<dcp::LanguageTag::SubtagData>()); boost::optional<dcp::LanguageTag::RegionSubtag> get() const; - boost::signals2::signal<void (boost::optional<dcp::LanguageTag::SubtagData>)> SelectionChanged; - boost::signals2::signal<void (std::string)> SearchChanged; + UISignal<void (boost::optional<dcp::LanguageTag::SubtagData>)> SelectionChanged; + UISignal<void (std::string)> SearchChanged; private: void search_changed(); diff --git a/src/wx/language_tag_widget.h b/src/wx/language_tag_widget.h index ff3eeb727..c7e88fd03 100644 --- a/src/wx/language_tag_widget.h +++ b/src/wx/language_tag_widget.h @@ -19,12 +19,12 @@ */ +#include "lib/signal.h" #include <dcp/language_tag.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class wxButton; @@ -52,7 +52,7 @@ public: void set (boost::optional<dcp::LanguageTag> tag); void enable (bool e); - boost::signals2::signal<void (dcp::LanguageTag)> Changed; + UISignal<void (dcp::LanguageTag)> Changed; private: void edit (); diff --git a/src/wx/name_format_editor.h b/src/wx/name_format_editor.h index b4fe5691e..a442d37e8 100644 --- a/src/wx/name_format_editor.h +++ b/src/wx/name_format_editor.h @@ -24,6 +24,7 @@ #include "lib/compose.hpp" +#include "lib/signal.h" #include <dcp/name_format.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS @@ -45,7 +46,7 @@ public: return _name; } - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; private: diff --git a/src/wx/password_entry.cc b/src/wx/password_entry.cc index a6378fdd0..661894a15 100644 --- a/src/wx/password_entry.cc +++ b/src/wx/password_entry.cc @@ -38,7 +38,7 @@ PasswordEntry::PasswordEntry (wxWindow* parent) _panel->SetSizerAndFit (sizer); _show->bind(&PasswordEntry::show_clicked, this); - _text->Bind(wxEVT_TEXT, boost::bind(boost::ref(Changed))); + _text->Bind(wxEVT_TEXT, [this](wxCommandEvent const&) { Changed(); }); } wxPanel * @@ -59,7 +59,7 @@ PasswordEntry::show_clicked () delete _text; _text = new wxTextCtrl (_panel, wxID_ANY, pass, wxDefaultPosition, wxDefaultSize, _show->GetValue() ? 0 : wxTE_PASSWORD); _text->SetSelection (from, to); - _text->Bind(wxEVT_TEXT, boost::bind(boost::ref(Changed))); + _text->Bind(wxEVT_TEXT, [this](wxCommandEvent const&) { Changed(); }); sizer->Prepend (_text, 1, wxRIGHT, DCPOMATIC_SIZER_GAP); sizer->Layout (); _panel->Thaw (); diff --git a/src/wx/password_entry.h b/src/wx/password_entry.h index f2d4f9ed0..e7b420e2d 100644 --- a/src/wx/password_entry.h +++ b/src/wx/password_entry.h @@ -19,11 +19,11 @@ */ +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class CheckBox; @@ -39,7 +39,7 @@ public: std::string get () const; void set (std::string); - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; private: void show_clicked (); diff --git a/src/wx/player_stress_tester.h b/src/wx/player_stress_tester.h index 534cf8c76..1307fac8e 100644 --- a/src/wx/player_stress_tester.h +++ b/src/wx/player_stress_tester.h @@ -19,11 +19,11 @@ */ +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> #include <boost/filesystem.hpp> @@ -62,7 +62,7 @@ public: _suspended = s; } - boost::signals2::signal<void (boost::filesystem::path)> LoadDCP; + UISignal<void (boost::filesystem::path)> LoadDCP; private: void check_commands (); diff --git a/src/wx/playlist_controls.h b/src/wx/playlist_controls.h index 76ec63824..96a73aff5 100644 --- a/src/wx/playlist_controls.h +++ b/src/wx/playlist_controls.h @@ -20,6 +20,7 @@ #include "controls.h" +#include "lib/signal.h" #include "lib/spl.h" @@ -35,7 +36,7 @@ public: when we have created one from a SPL. We could call a method in the player's DOMFrame but we don't have that in a header. */ - boost::signals2::signal<void (std::weak_ptr<Film>)> ResetFilm; + UISignal<void (std::weak_ptr<Film>)> ResetFilm; void play () override; void stop () override; diff --git a/src/wx/rating_dialog.h b/src/wx/rating_dialog.h index e8dfc2d9c..f7e2f9697 100644 --- a/src/wx/rating_dialog.h +++ b/src/wx/rating_dialog.h @@ -19,12 +19,12 @@ */ +#include "lib/signal.h" #include <dcp/rating.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class wxChoice; @@ -43,7 +43,7 @@ public: /** Emitted when the page has been changed, the parameter being true if OK * should now be enabled in the main dialogue. */ - boost::signals2::signal<void (bool)> Changed; + UISignal<void (bool)> Changed; }; diff --git a/src/wx/recipients_panel.h b/src/wx/recipients_panel.h index cecfa3d33..ee613d6eb 100644 --- a/src/wx/recipients_panel.h +++ b/src/wx/recipients_panel.h @@ -22,13 +22,13 @@ #include "lib/collator.h" #include "lib/dkdm_recipient.h" #include "lib/dkdm_recipient_list.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/srchctrl.h> #include <wx/treectrl.h> #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> #include <list> #include <map> @@ -47,7 +47,7 @@ public: /** @return List of selected recipients */ std::list<DKDMRecipient> recipients() const; - boost::signals2::signal<void ()> RecipientsChanged; + UISignal<void ()> RecipientsChanged; private: void add_recipients (); diff --git a/src/wx/region_subtag_widget.h b/src/wx/region_subtag_widget.h index 725f8652c..16c622358 100644 --- a/src/wx/region_subtag_widget.h +++ b/src/wx/region_subtag_widget.h @@ -19,12 +19,12 @@ */ +#include "lib/signal.h" #include <dcp/language_tag.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> class wxButton; @@ -54,7 +54,7 @@ public: void set(boost::optional<dcp::LanguageTag::RegionSubtag> tag); void enable(bool e); - boost::signals2::signal<void (boost::optional<dcp::LanguageTag::RegionSubtag>)> Changed; + UISignal<void (boost::optional<dcp::LanguageTag::RegionSubtag>)> Changed; private: void edit (); diff --git a/src/wx/screens_panel.h b/src/wx/screens_panel.h index 07f72f9a8..a9b6529df 100644 --- a/src/wx/screens_panel.h +++ b/src/wx/screens_panel.h @@ -22,13 +22,13 @@ #include "lib/cinema_list.h" #include "lib/collator.h" #include "lib/config.h" +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/srchctrl.h> #include <wx/treelist.h> #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> #include <list> #include <map> #include <set> @@ -57,7 +57,7 @@ public: dcp::UTCOffset best_utc_offset() const; - boost::signals2::signal<void ()> ScreensChanged; + UISignal<void ()> ScreensChanged; private: void add_cinemas (); diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index 31f413a36..df4fce596 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -61,7 +61,7 @@ SimpleVideoView::SimpleVideoView (FilmViewer* viewer, wxWindow* parent) _panel->SetBackgroundColour (*wxBLACK); _panel->Bind (wxEVT_PAINT, boost::bind (&SimpleVideoView::paint, this)); - _panel->Bind (wxEVT_SIZE, boost::bind(boost::ref(Sized))); + _panel->Bind (wxEVT_SIZE, [this](wxSizeEvent const&) { Sized.emit_ui(this); }); _timer.Bind (wxEVT_TIMER, boost::bind(&SimpleVideoView::timer, this)); } diff --git a/src/wx/time_picker.h b/src/wx/time_picker.h index 50177afd3..58b3cea05 100644 --- a/src/wx/time_picker.h +++ b/src/wx/time_picker.h @@ -19,6 +19,7 @@ */ +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> @@ -36,7 +37,7 @@ public: virtual int hours () const = 0; virtual int minutes () const = 0; - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; }; diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 53cd93694..fb901a006 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -25,13 +25,13 @@ #include "wx_util.h" #include "lib/dcpomatic_time.h" +#include "lib/signal.h" #include <dcp/raw_convert.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS #include <fmt/format.h> -#include <boost/signals2.hpp> class TimecodeBase : public wxPanel @@ -44,7 +44,7 @@ public: void set_editable (bool); void set_focus (); - boost::signals2::signal<void ()> Changed; + UISignal<void ()> Changed; static wxSize size (wxWindow* parent); diff --git a/src/wx/video_view.cc b/src/wx/video_view.cc index 2c6a637ea..902853772 100644 --- a/src/wx/video_view.cc +++ b/src/wx/video_view.cc @@ -170,7 +170,7 @@ VideoView::add_dropped () } if (too_many) { - emit (boost::bind(boost::ref(TooManyDropped))); + TooManyDropped.emit_ui(this); } } diff --git a/src/wx/video_view.h b/src/wx/video_view.h index 04c52a35d..f24aff790 100644 --- a/src/wx/video_view.h +++ b/src/wx/video_view.h @@ -26,6 +26,7 @@ #include "optimisation.h" #include "lib/dcpomatic_time.h" #include "lib/exception_store.h" +#include "lib/signal.h" #include "lib/signaller.h" #include "lib/timer.h" #include "lib/types.h" @@ -76,9 +77,9 @@ public: bool reset_metadata (std::shared_ptr<const Film> film, dcp::Size player_video_container_size); /** Emitted from the GUI thread when our display changes in size */ - boost::signals2::signal<void()> Sized; + UISignal<void()> Sized; /** Emitted from the GUI thread when a lot of frames are being dropped */ - boost::signals2::signal<void()> TooManyDropped; + UISignal<void()> TooManyDropped; /* Accessors for FilmViewer */ diff --git a/src/wx/video_waveform_plot.h b/src/wx/video_waveform_plot.h index e6e7a6f3d..1dae59462 100644 --- a/src/wx/video_waveform_plot.h +++ b/src/wx/video_waveform_plot.h @@ -19,11 +19,11 @@ */ +#include "lib/signal.h" #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> LIBDCP_ENABLE_WARNINGS -#include <boost/signals2.hpp> namespace dcp { @@ -50,7 +50,7 @@ public: - (int, int): image x range - (int, int): component value range */ - boost::signals2::signal<void (int, int, int, int)> MouseMoved; + UISignal<void (int, int, int, int)> MouseMoved; private: void paint (); |
