From a12a943c99ba4aba122f91c93b078d2e87146b32 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 12 Jun 2025 00:27:33 +0200 Subject: Use a new UISignal which checks thread safety slightly. 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. --- src/wx/audio_mapping_view.h | 4 ++-- src/wx/audio_plot.h | 4 ++-- src/wx/auto_crop_dialog.h | 4 ++-- src/wx/colour_conversion_editor.h | 4 ++-- src/wx/content_panel.h | 3 ++- src/wx/dcp_timeline.cc | 3 ++- src/wx/dir_picker_ctrl.h | 3 ++- src/wx/dkdm_output_panel.h | 3 ++- src/wx/editable_list.h | 2 +- src/wx/film_editor.h | 2 +- src/wx/film_viewer.cc | 4 ++-- src/wx/film_viewer.h | 12 +++++++----- src/wx/filter_dialog.h | 4 ++-- src/wx/focus_manager.h | 5 +++-- src/wx/kdm_cpl_panel.h | 3 ++- src/wx/kdm_output_panel.h | 3 ++- src/wx/kdm_timing_panel.h | 3 ++- src/wx/language_subtag_panel.h | 5 +++-- src/wx/language_tag_widget.h | 4 ++-- src/wx/name_format_editor.h | 3 ++- src/wx/password_entry.cc | 4 ++-- src/wx/password_entry.h | 4 ++-- src/wx/player_stress_tester.h | 4 ++-- src/wx/playlist_controls.h | 3 ++- src/wx/rating_dialog.h | 4 ++-- src/wx/recipients_panel.h | 4 ++-- src/wx/region_subtag_widget.h | 4 ++-- src/wx/screens_panel.h | 4 ++-- src/wx/simple_video_view.cc | 2 +- src/wx/time_picker.h | 3 ++- src/wx/timecode.h | 4 ++-- src/wx/video_view.cc | 2 +- src/wx/video_view.h | 5 +++-- src/wx/video_waveform_plot.h | 4 ++-- 34 files changed, 72 insertions(+), 57 deletions(-) (limited to 'src/wx') 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include /** @class AudioMappingView @@ -74,7 +74,7 @@ public: void set_input_groups (std::vector const & groups); - boost::signals2::signal Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include #include struct Metrics; @@ -45,7 +45,7 @@ public: wxColour colour (int n) const; - boost::signals2::signal, boost::optional)> Cursor; + UISignal, boost::optional)> 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 +#include "lib/signal.h" class SpinCtrl; @@ -39,7 +39,7 @@ public: Crop get () const; void set (Crop crop); - boost::signals2::signal Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include class ColourConversion; @@ -43,7 +43,7 @@ public: void set (ColourConversion); ColourConversion get () const; - boost::signals2::signal Changed; + UISignal 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 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 SelectionChanged; + UISignal 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 @@ -121,7 +122,7 @@ public: return _view; } - boost::signals2::signal Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include @@ -41,7 +42,7 @@ public: wxString GetPath() const; void SetPath(wxString); - boost::signals2::signal Changed; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS @@ -56,7 +57,7 @@ public: bool method_selected() const; - boost::signals2::signal MethodChanged; + UISignal 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 SelectionChanged; + UISignal 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); void first_shown (); - boost::signals2::signal SelectionChanged; + UISignal 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()); @@ -866,7 +866,7 @@ void FilmViewer::image_changed(shared_ptr 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 ImageChanged; + UISignal ImageChanged; std::shared_ptr last_image() const; - boost::signals2::signal Started; - boost::signals2::signal Stopped; + UISignal Started; + UISignal Stopped; /** While playing back we reached the end of the film (emitted from GUI thread) */ - boost::signals2::signal Finished; + UISignal Finished; /** Emitted from the GUI thread when a lot of frames are being dropped */ - boost::signals2::signal TooManyDropped; + UISignal TooManyDropped; + /* XXX: could be UISignal but this needs a return type and that is tricky in C++11 AFAICS */ boost::signals2::signal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include class Film; @@ -43,7 +43,7 @@ class FilterDialog : public wxDialog public: FilterDialog(wxWindow *, std::vector const&); - boost::signals2::signal)> ActiveChanged; + UISignal)> 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 @@ -38,9 +39,9 @@ class FocusManager { public: /** emitted when any add()ed TextCtrl gets focus */ - boost::signals2::signal SetFocus; + UISignal SetFocus; /** emitted when any add()ed TextCtrl loses focus */ - boost::signals2::signal KillFocus; + UISignal 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 LIBDCP_DISABLE_WARNINGS @@ -36,7 +37,7 @@ public: boost::filesystem::path cpl () const; bool has_selected () const; - boost::signals2::signal Changed; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS @@ -73,7 +74,7 @@ public: void set_annotation_text(std::string text); std::string annotation_text() const; - boost::signals2::signal MethodChanged; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS @@ -49,7 +50,7 @@ public: */ void suggest_utc_offset(dcp::UTCOffset offset); - boost::signals2::signal TimingChanged; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include @@ -39,8 +40,8 @@ public: void set(dcp::LanguageTag::SubtagType type, std::string search, boost::optional subtag = boost::optional()); boost::optional get() const; - boost::signals2::signal)> SelectionChanged; - boost::signals2::signal SearchChanged; + UISignal)> SelectionChanged; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include class wxButton; @@ -52,7 +52,7 @@ public: void set (boost::optional tag); void enable (bool e); - boost::signals2::signal Changed; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS @@ -45,7 +46,7 @@ public: return _name; } - boost::signals2::signal Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include class CheckBox; @@ -39,7 +39,7 @@ public: std::string get () const; void set (std::string); - boost::signals2::signal Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include #include @@ -62,7 +62,7 @@ public: _suspended = s; } - boost::signals2::signal LoadDCP; + UISignal 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)> ResetFilm; + UISignal)> 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 #include LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include 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 Changed; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include #include #include LIBDCP_ENABLE_WARNINGS -#include #include #include @@ -47,7 +47,7 @@ public: /** @return List of selected recipients */ std::list recipients() const; - boost::signals2::signal RecipientsChanged; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include class wxButton; @@ -54,7 +54,7 @@ public: void set(boost::optional tag); void enable(bool e); - boost::signals2::signal)> Changed; + UISignal)> 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 LIBDCP_DISABLE_WARNINGS #include #include #include LIBDCP_ENABLE_WARNINGS -#include #include #include #include @@ -57,7 +57,7 @@ public: dcp::UTCOffset best_utc_offset() const; - boost::signals2::signal ScreensChanged; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include @@ -36,7 +37,7 @@ public: virtual int hours () const = 0; virtual int minutes () const = 0; - boost::signals2::signal Changed; + UISignal 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 #include LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS #include -#include class TimecodeBase : public wxPanel @@ -44,7 +44,7 @@ public: void set_editable (bool); void set_focus (); - boost::signals2::signal Changed; + UISignal 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 film, dcp::Size player_video_container_size); /** Emitted from the GUI thread when our display changes in size */ - boost::signals2::signal Sized; + UISignal Sized; /** Emitted from the GUI thread when a lot of frames are being dropped */ - boost::signals2::signal TooManyDropped; + UISignal 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 LIBDCP_DISABLE_WARNINGS #include LIBDCP_ENABLE_WARNINGS -#include namespace dcp { @@ -50,7 +50,7 @@ public: - (int, int): image x range - (int, int): component value range */ - boost::signals2::signal MouseMoved; + UISignal MouseMoved; private: void paint (); -- cgit v1.2.3