Stop threads at the start of their object's destruction in all Job cases.
authorCarl Hetherington <cth@carlh.net>
Fri, 6 Mar 2020 21:36:16 +0000 (22:36 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 6 Mar 2020 21:36:16 +0000 (22:36 +0100)
19 files changed:
src/lib/analyse_audio_job.cc
src/lib/check_content_change_job.cc
src/lib/check_content_change_job.h
src/lib/examine_content_job.cc
src/lib/examine_content_job.h
src/lib/examine_ffmpeg_subtitles_job.cc
src/lib/examine_ffmpeg_subtitles_job.h
src/lib/job.cc
src/lib/send_kdm_email_job.cc
src/lib/send_kdm_email_job.h
src/lib/send_notification_email_job.cc
src/lib/send_notification_email_job.h
src/lib/send_problem_report_job.cc
src/lib/send_problem_report_job.h
src/lib/transcode_job.cc
src/lib/upload_job.cc
src/lib/upload_job.h
src/lib/verify_dcp_job.cc
src/lib/verify_dcp_job.h

index 9d0882b..ad28dcf 100644 (file)
@@ -83,6 +83,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
 
 AnalyseAudioJob::~AnalyseAudioJob ()
 {
+       stop_thread ();
        BOOST_FOREACH (Filter const * i, _filters) {
                delete const_cast<Filter*> (i);
        }
index e1226e7..1df3bc9 100644 (file)
@@ -42,6 +42,11 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr<const Film> film, share
 
 }
 
+CheckContentChangeJob::~CheckContentChangeJob ()
+{
+       stop_thread ();
+}
+
 string
 CheckContentChangeJob::name () const
 {
index 355dedf..152cdb9 100644 (file)
@@ -28,6 +28,7 @@ class CheckContentChangeJob : public Job
 {
 public:
        CheckContentChangeJob (boost::shared_ptr<const Film>, boost::shared_ptr<Job> following = boost::shared_ptr<Job>(), bool gui = true);
+       ~CheckContentChangeJob ();
 
        std::string name () const;
        std::string json_name () const;
index 86e0a10..3be3886 100644 (file)
@@ -38,6 +38,11 @@ ExamineContentJob::ExamineContentJob (shared_ptr<const Film> film, shared_ptr<Co
 
 }
 
+ExamineContentJob::~ExamineContentJob ()
+{
+       stop_thread ();
+}
+
 string
 ExamineContentJob::name () const
 {
index 4249637..0105035 100644 (file)
@@ -27,6 +27,7 @@ class ExamineContentJob : public Job
 {
 public:
        ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>);
+       ~ExamineContentJob ();
 
        std::string name () const;
        std::string json_name () const;
index b9d5f54..b2bba11 100644 (file)
@@ -43,6 +43,11 @@ ExamineFFmpegSubtitlesJob::ExamineFFmpegSubtitlesJob (shared_ptr<const Film> fil
 
 }
 
+ExamineFFmpegSubtitlesJob::~ExamineFFmpegSubtitlesJob ()
+{
+       stop_thread ();
+}
+
 string
 ExamineFFmpegSubtitlesJob::name () const
 {
index 5960a9c..0a01011 100644 (file)
@@ -28,6 +28,7 @@ class ExamineFFmpegSubtitlesJob : public Job, public FFmpeg
 {
 public:
        ExamineFFmpegSubtitlesJob (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>);
+       ~ExamineFFmpegSubtitlesJob ();
 
        std::string name () const;
        std::string json_name () const;
index 04aa227..a83249e 100644 (file)
@@ -62,7 +62,10 @@ Job::Job (shared_ptr<const Film> film)
 
 Job::~Job ()
 {
-       stop_thread ();
+#ifdef DCPOMATIC_DEBUG
+       /* Any subclass should have called stop_thread in its destructor */
+       assert (!_thread.joinable());
+#endif
 }
 
 void
index 38484b9..1b476fa 100644 (file)
@@ -53,6 +53,11 @@ SendKDMEmailJob::SendKDMEmailJob (
 
 }
 
+SendKDMEmailJob::~SendKDMEmailJob ()
+{
+       stop_thread ();
+}
+
 string
 SendKDMEmailJob::name () const
 {
index 0b64db7..a7196fe 100644 (file)
@@ -40,6 +40,7 @@ public:
                dcp::NameFormat::Map name_values,
                std::string cpl_name
                );
+       ~SendKDMEmailJob ();
 
        std::string name () const;
        std::string json_name () const;
index abbb844..1c9d963 100644 (file)
@@ -40,6 +40,11 @@ SendNotificationEmailJob::SendNotificationEmailJob (string body)
 
 }
 
+SendNotificationEmailJob::~SendNotificationEmailJob ()
+{
+       stop_thread ();
+}
+
 string
 SendNotificationEmailJob::name () const
 {
index 04f1d98..5c116f2 100644 (file)
@@ -24,6 +24,7 @@ class SendNotificationEmailJob : public Job
 {
 public:
        explicit SendNotificationEmailJob (std::string body);
+       ~SendNotificationEmailJob ();
 
        std::string name () const;
        std::string json_name () const;
index 11f700d..d27609f 100644 (file)
@@ -52,6 +52,11 @@ SendProblemReportJob::SendProblemReportJob (
 
 }
 
+SendProblemReportJob::~SendProblemReportJob ()
+{
+       stop_thread ();
+}
+
 string
 SendProblemReportJob::name () const
 {
index c4371a5..af1a4b2 100644 (file)
@@ -31,6 +31,8 @@ public:
                std::string summary
                );
 
+       ~SendProblemReportJob ();
+
        std::string name () const;
        std::string json_name () const;
        void run ();
index 7fe28d2..fb586b0 100644 (file)
@@ -54,9 +54,6 @@ TranscodeJob::TranscodeJob (shared_ptr<const Film> film)
 
 TranscodeJob::~TranscodeJob ()
 {
-       /* We have to stop the job thread here as we're about to start tearing down
-          the Encoder, which is bad news if the job thread is still feeding it data.
-       */
        stop_thread ();
 }
 
index b229fdd..fbfbb92 100644 (file)
@@ -46,6 +46,11 @@ UploadJob::UploadJob (shared_ptr<const Film> film)
 
 }
 
+UploadJob::~UploadJob ()
+{
+       stop_thread ();
+}
+
 string
 UploadJob::name () const
 {
index 407094a..3a613fd 100644 (file)
@@ -28,6 +28,7 @@ class UploadJob : public Job
 {
 public:
        explicit UploadJob (boost::shared_ptr<const Film>);
+       ~UploadJob ();
 
        std::string name () const;
        std::string json_name () const;
index 908cd53..c1dcbc7 100644 (file)
@@ -36,6 +36,11 @@ VerifyDCPJob::VerifyDCPJob (vector<boost::filesystem::path> directories)
 
 }
 
+VerifyDCPJob::~VerifyDCPJob ()
+{
+       stop_thread ();
+}
+
 string
 VerifyDCPJob::name () const
 {
index a93a7ad..2cff5ab 100644 (file)
@@ -28,6 +28,7 @@ class VerifyDCPJob : public Job
 {
 public:
        explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories);
+       ~VerifyDCPJob ();
 
        std::string name () const;
        std::string json_name () const;