summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-10-26 22:58:18 +0100
committerCarl Hetherington <cth@carlh.net>2025-10-27 00:48:38 +0100
commita5dd7e1b70911288e7a3ba6ad43e72982aba2b9f (patch)
tree5389c87f805bb58fb5f872760c3a5ef8950535f2
parentf1dfe9f2666c171ccaf5fc06c4e2395dda807e89 (diff)
Use new signal handling for Hints.
-rw-r--r--src/lib/encode_cli.cc8
-rw-r--r--src/lib/hints.cc14
-rw-r--r--src/lib/hints.h13
-rw-r--r--src/tools/dcpomatic.cc3
-rw-r--r--src/tools/dcpomatic_cli.cc2
-rw-r--r--src/wx/hints_dialog.cc8
-rw-r--r--src/wx/hints_dialog.h11
-rw-r--r--test/hints_test.cc5
8 files changed, 35 insertions, 29 deletions
diff --git a/src/lib/encode_cli.cc b/src/lib/encode_cli.cc
index 8bf1a4a26..4e348bdc5 100644
--- a/src/lib/encode_cli.cc
+++ b/src/lib/encode_cli.cc
@@ -536,19 +536,19 @@ encode_cli(int argc, char* argv[], function<void (string)> out, function<void ()
bool finished = false;
Hints hint_finder(film);
- hint_finder.Progress.connect([prefix, &out, &flush](string progress) {
+ hint_finder.Progress.connect_ui_thread(nullptr, [prefix, &out, &flush](string progress) {
out(fmt::format("{}{}: {}\n", UP_ONE_LINE_AND_ERASE, prefix, progress));
flush();
});
- hint_finder.Pulse.connect([prefix, &pulse_phase, &out, &flush]() {
+ hint_finder.Pulse.connect_ui_thread(nullptr, [prefix, &pulse_phase, &out, &flush]() {
out(fmt::format("{}{}: {}\n", UP_ONE_LINE_AND_ERASE, prefix, pulse_phase ? "X" : "x"));
flush();
pulse_phase = !pulse_phase;
});
- hint_finder.Hint.connect([&hints](string hint) {
+ hint_finder.Hint.connect_ui_thread(nullptr, [&hints](string hint) {
hints.push_back(hint);
});
- hint_finder.Finished.connect([&finished]() {
+ hint_finder.Finished.connect_ui_thread(nullptr, [&finished]() {
finished = true;
});
diff --git a/src/lib/hints.cc b/src/lib/hints.cc
index cf385216e..27835aed2 100644
--- a/src/lib/hints.cc
+++ b/src/lib/hints.cc
@@ -410,11 +410,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(_("Examining subtitles and closed captions"));
} else if (!check_loudness_done && !have_text) {
- emit(boost::bind(boost::ref(Progress), _("Examining audio")));
+ Progress(_("Examining audio"));
} else {
- emit(boost::bind(boost::ref(Progress), _("Examining audio, subtitles and closed captions")));
+ Progress(_("Examining audio, subtitles and closed captions"));
}
auto player = make_shared<Player>(film, Image::Alignment::COMPACT, false);
@@ -441,7 +441,7 @@ Hints::scan_content(shared_ptr<const Film> film)
if (_stop) {
return;
}
- emit(boost::bind(boost::ref(Pulse)));
+ Pulse();
last_pulse = now;
}
}
@@ -535,7 +535,7 @@ try
}
dcp::filesystem::remove_all(dcp_dir);
- emit(boost::bind(boost::ref(Finished)));
+ Finished();
}
catch (boost::thread_interrupted)
{
@@ -544,14 +544,14 @@ catch (boost::thread_interrupted)
catch (...)
{
store_current();
- emit(boost::bind(boost::ref(Finished)));
+ Finished();
}
void
Hints::hint(string h)
{
- emit(boost::bind(boost::ref(Hint), h));
+ Hint(h);
}
diff --git a/src/lib/hints.h b/src/lib/hints.h
index 49fd32ea9..4e266c964 100644
--- a/src/lib/hints.h
+++ b/src/lib/hints.h
@@ -23,11 +23,10 @@
#include "dcp_text_track.h"
#include "dcpomatic_time.h"
#include "player_text.h"
-#include "signaller.h"
+#include "signal.h"
#include "text_type.h"
#include "weak_film.h"
#include <boost/atomic.hpp>
-#include <boost/signals2.hpp>
#include <string>
#include <vector>
@@ -36,7 +35,7 @@ class Film;
class Writer;
-class Hints : public Signaller, public ExceptionStore, public WeakConstFilm
+class Hints : public ExceptionStore, public WeakConstFilm
{
public:
explicit Hints(std::weak_ptr<const Film> film);
@@ -44,10 +43,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;
+ Signal<void (std::string)> Hint;
+ Signal<void (std::string)> Progress;
+ Signal<void (void)> Pulse;
+ Signal<void (void)> Finished;
/* For tests only */
void join();
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index e0c69f5a4..13ad5d029 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -55,6 +55,7 @@
#include "wx/templates_dialog.h"
#include "wx/update_dialog.h"
#include "wx/video_waveform_dialog.h"
+#include "wx/wx_signal.h"
#include "wx/wx_signal_manager.h"
#include "wx/wx_util.h"
#include "wx/wx_variant.h"
@@ -1725,6 +1726,7 @@ private:
_frame->Show ();
signal_manager = new wxSignalManager (this);
+ dcpomatic::signal::manager = new wxSignalManager2(this);
Bind (wxEVT_IDLE, boost::bind (&App::idle, this, _1));
if (!_film_to_load.empty() && dcp::filesystem::is_directory(_film_to_load)) {
@@ -1867,6 +1869,7 @@ private:
void idle (wxIdleEvent& ev)
{
signal_manager->ui_idle ();
+ dcpomatic::signal::manager->process_pending();
ev.Skip ();
}
diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc
index 27934e664..c1299b21b 100644
--- a/src/tools/dcpomatic_cli.cc
+++ b/src/tools/dcpomatic_cli.cc
@@ -26,6 +26,7 @@
#include "lib/cross.h"
#include "lib/encode_cli.h"
+#include "lib/signal.h"
#include "lib/signal_manager.h"
#include "lib/util.h"
#include <iostream>
@@ -40,6 +41,7 @@ main(int argc, char* argv[])
dcpomatic_setup();
signal_manager = new SignalManager();
+ dcpomatic::signal::manager = new SignalManager2();
auto error = encode_cli(fixer.argc(), fixer.argv(), [](std::string s) { std::cout << s; }, []() { std::cout.flush(); });
if (error) {
diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc
index 974d6f4cf..a248584a5 100644
--- a/src/wx/hints_dialog.cc
+++ b/src/wx/hints_dialog.cc
@@ -122,10 +122,10 @@ HintsDialog::film_change(ChangeType type)
_finished = false;
_hints.reset(new Hints(_film));
- _hints_hint_connection = _hints->Hint.connect(bind(&HintsDialog::hint, this, _1));
- _hints_progress_connection = _hints->Progress.connect(bind(&HintsDialog::progress, this, _1));
- _hints_pulse_connection = _hints->Pulse.connect(bind(&HintsDialog::pulse, this));
- _hints_finished_connection = _hints->Finished.connect(bind(&HintsDialog::finished, this));
+ _hints_hint_connection = _hints->Hint.connect_ui_thread(this, bind(&HintsDialog::hint, this, _1));
+ _hints_progress_connection = _hints->Progress.connect_ui_thread(this, bind(&HintsDialog::progress, this, _1));
+ _hints_pulse_connection = _hints->Pulse.connect_ui_thread(this, bind(&HintsDialog::pulse, this));
+ _hints_finished_connection = _hints->Finished.connect_ui_thread(this, bind(&HintsDialog::finished, this));
_hints->start();
}
diff --git a/src/wx/hints_dialog.h b/src/wx/hints_dialog.h
index 44420405a..e84afbb59 100644
--- a/src/wx/hints_dialog.h
+++ b/src/wx/hints_dialog.h
@@ -20,6 +20,7 @@
#include "lib/change_signaller.h"
+#include "lib/signal.h"
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/wx.h>
@@ -31,7 +32,7 @@ class wxRichTextCtrl;
class Film;
class Hints;
-class HintsDialog : public wxDialog
+class HintsDialog : public wxDialog, public Trackable
{
public:
HintsDialog(wxWindow* parent, std::weak_ptr<Film>, bool ok);
@@ -56,8 +57,8 @@ private:
boost::signals2::scoped_connection _film_change_connection;
boost::signals2::scoped_connection _film_content_change_connection;
- boost::signals2::scoped_connection _hints_hint_connection;
- boost::signals2::scoped_connection _hints_progress_connection;
- boost::signals2::scoped_connection _hints_pulse_connection;
- boost::signals2::scoped_connection _hints_finished_connection;
+ ScopedConnection _hints_hint_connection;
+ ScopedConnection _hints_progress_connection;
+ ScopedConnection _hints_pulse_connection;
+ ScopedConnection _hints_finished_connection;
};
diff --git a/test/hints_test.cc b/test/hints_test.cc
index 55bd9d77f..12cfb0011 100644
--- a/test/hints_test.cc
+++ b/test/hints_test.cc
@@ -28,6 +28,7 @@
#include "lib/film.h"
#include "lib/font.h"
#include "lib/hints.h"
+#include "lib/signal.h"
#include "lib/text_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
@@ -59,10 +60,10 @@ get_hints (shared_ptr<Film> film)
Hints hints (film);
/* None of our tests need the audio analysis, and it is quite time-consuming */
hints.disable_audio_analysis ();
- hints.Hint.connect (collect_hint);
+ hints.Hint.connect_ui_thread(nullptr, collect_hint);
hints.start ();
hints.join ();
- while (signal_manager->ui_idle()) {}
+ dcpomatic::signal::manager->wake();
hints.rethrow();
return current_hints;
}