summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-12-05 00:24:56 +0100
committerCarl Hetherington <cth@carlh.net>2021-12-06 22:42:06 +0100
commit03f138ee007efd175c85d7c63f8deec567065d89 (patch)
tree7d76f7f482525a05f1bd6c37d04117c66346850e /src
parent6e93ff6ac5b514d1b8dd9ccb2d6372576a52761a (diff)
Use a virtual method rather than a set of nasty dynamic casts.
Diffstat (limited to 'src')
-rw-r--r--src/lib/analyse_audio_job.h9
-rw-r--r--src/lib/job.h4
-rw-r--r--src/lib/transcode_job.h3
-rw-r--r--src/wx/job_view.cc3
4 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h
index 864a6a7cd..f8311da47 100644
--- a/src/lib/analyse_audio_job.h
+++ b/src/lib/analyse_audio_job.h
@@ -54,9 +54,12 @@ public:
AnalyseAudioJob (std::shared_ptr<const Film>, std::shared_ptr<const Playlist>, bool from_zero);
~AnalyseAudioJob ();
- std::string name () const;
- std::string json_name () const;
- void run ();
+ std::string name () const override;
+ std::string json_name () const override;
+ void run () override;
+ bool enable_notify () const override {
+ return true;
+ }
boost::filesystem::path path () const {
return _path;
diff --git a/src/lib/job.h b/src/lib/job.h
index b44fd1365..8b89fd0c3 100644
--- a/src/lib/job.h
+++ b/src/lib/job.h
@@ -50,6 +50,10 @@ public:
virtual std::string json_name () const = 0;
/** Run this job in the current thread. */
virtual void run () = 0;
+ /** @return true if it should be possible to notify when this job finishes */
+ virtual bool enable_notify () const {
+ return false;
+ }
void start ();
bool pause_by_user ();
diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h
index 368a9b685..6b2e8f923 100644
--- a/src/lib/transcode_job.h
+++ b/src/lib/transcode_job.h
@@ -57,6 +57,9 @@ public:
std::string json_name () const override;
void run () override;
std::string status () const override;
+ bool enable_notify () const override {
+ return true;
+ }
void set_encoder (std::shared_ptr<Encoder> t);
diff --git a/src/wx/job_view.cc b/src/wx/job_view.cc
index 776201424..06d10401f 100644
--- a/src/wx/job_view.cc
+++ b/src/wx/job_view.cc
@@ -40,7 +40,6 @@ using std::string;
using std::min;
using std::shared_ptr;
using boost::bind;
-using std::dynamic_pointer_cast;
JobView::JobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wxFlexGridSizer* table)
@@ -159,7 +158,7 @@ JobView::finished ()
d->Destroy ();
}
- if ((dynamic_pointer_cast<TranscodeJob>(_job) || dynamic_pointer_cast<AnalyseAudioJob>(_job)) && _notify->GetValue()) {
+ if (_job->enable_notify() && _notify->GetValue()) {
if (Config::instance()->notification(Config::MESSAGE_BOX)) {
wxMessageBox (std_to_wx(_job->name() + ": " + _job->status()), _("DCP-o-matic"), wxICON_INFORMATION);
}