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 9d0882b3ad22b3061f243d53ae78f91146042d3d..ad28dcfd40892695f211c36f06b65188651b20e5 100644 (file)
@@ -83,6 +83,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const
 
 AnalyseAudioJob::~AnalyseAudioJob ()
 {
 
 AnalyseAudioJob::~AnalyseAudioJob ()
 {
+       stop_thread ();
        BOOST_FOREACH (Filter const * i, _filters) {
                delete const_cast<Filter*> (i);
        }
        BOOST_FOREACH (Filter const * i, _filters) {
                delete const_cast<Filter*> (i);
        }
index e1226e79c6af3ae7c21cc74115875f9711a1111d..1df3bc9cda1f945a15e87c41091214a3a1dc14fa 100644 (file)
@@ -42,6 +42,11 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr<const Film> film, share
 
 }
 
 
 }
 
+CheckContentChangeJob::~CheckContentChangeJob ()
+{
+       stop_thread ();
+}
+
 string
 CheckContentChangeJob::name () const
 {
 string
 CheckContentChangeJob::name () const
 {
index 355dedf83a9d3ad2326b357918da855c39880190..152cdb9e7338f11f0a174333555476e3005be38f 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);
 {
 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;
 
        std::string name () const;
        std::string json_name () const;
index 86e0a107e1eec1d6351ded90b132e1a24a3a16e3..3be38863d46e4204bf364da3989ee4b1d7e0fe19 100644 (file)
@@ -38,6 +38,11 @@ ExamineContentJob::ExamineContentJob (shared_ptr<const Film> film, shared_ptr<Co
 
 }
 
 
 }
 
+ExamineContentJob::~ExamineContentJob ()
+{
+       stop_thread ();
+}
+
 string
 ExamineContentJob::name () const
 {
 string
 ExamineContentJob::name () const
 {
index 42496372638878773e61f962524d78848b89057d..0105035ffe1c175521680f1fc059869836e5bdc2 100644 (file)
@@ -27,6 +27,7 @@ class ExamineContentJob : public Job
 {
 public:
        ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>);
 {
 public:
        ExamineContentJob (boost::shared_ptr<const Film>, boost::shared_ptr<Content>);
+       ~ExamineContentJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;
index b9d5f54e5d09385f21406a52683dd4cfbe60abd7..b2bba11cd05707acf1c32647e48dc2754bcd3d2a 100644 (file)
@@ -43,6 +43,11 @@ ExamineFFmpegSubtitlesJob::ExamineFFmpegSubtitlesJob (shared_ptr<const Film> fil
 
 }
 
 
 }
 
+ExamineFFmpegSubtitlesJob::~ExamineFFmpegSubtitlesJob ()
+{
+       stop_thread ();
+}
+
 string
 ExamineFFmpegSubtitlesJob::name () const
 {
 string
 ExamineFFmpegSubtitlesJob::name () const
 {
index 5960a9cc3bad241c403b4910bcf1852825d8c319..0a0101193c0067b34c9d25af15ae4c990962d37d 100644 (file)
@@ -28,6 +28,7 @@ class ExamineFFmpegSubtitlesJob : public Job, public FFmpeg
 {
 public:
        ExamineFFmpegSubtitlesJob (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>);
 {
 public:
        ExamineFFmpegSubtitlesJob (boost::shared_ptr<const Film>, boost::shared_ptr<FFmpegContent>);
+       ~ExamineFFmpegSubtitlesJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;
index 04aa227b7a46c749f03c6ae56e6eb43a66645f38..a83249e798feba99abafc2a09f1393eb8cf5dc18 100644 (file)
@@ -62,7 +62,10 @@ Job::Job (shared_ptr<const Film> film)
 
 Job::~Job ()
 {
 
 Job::~Job ()
 {
-       stop_thread ();
+#ifdef DCPOMATIC_DEBUG
+       /* Any subclass should have called stop_thread in its destructor */
+       assert (!_thread.joinable());
+#endif
 }
 
 void
 }
 
 void
index 38484b91e15500333184422541b45c77e763c396..1b476fa63e7312a1ea67710a45e2fc0a6c88b384 100644 (file)
@@ -53,6 +53,11 @@ SendKDMEmailJob::SendKDMEmailJob (
 
 }
 
 
 }
 
+SendKDMEmailJob::~SendKDMEmailJob ()
+{
+       stop_thread ();
+}
+
 string
 SendKDMEmailJob::name () const
 {
 string
 SendKDMEmailJob::name () const
 {
index 0b64db7a8879c64bf4baf5392444e72b3ba4f204..a7196fe15ca679e1c20d1c2e04a20556987e9fc6 100644 (file)
@@ -40,6 +40,7 @@ public:
                dcp::NameFormat::Map name_values,
                std::string cpl_name
                );
                dcp::NameFormat::Map name_values,
                std::string cpl_name
                );
+       ~SendKDMEmailJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;
index abbb844e2f5c2fe6b2a5b72ba3607d94dbd4f7ab..1c9d963388a1eefd1451984481f4b05f1df5484b 100644 (file)
@@ -40,6 +40,11 @@ SendNotificationEmailJob::SendNotificationEmailJob (string body)
 
 }
 
 
 }
 
+SendNotificationEmailJob::~SendNotificationEmailJob ()
+{
+       stop_thread ();
+}
+
 string
 SendNotificationEmailJob::name () const
 {
 string
 SendNotificationEmailJob::name () const
 {
index 04f1d98ab82f62b77fe184b4cf9c3300e13b0fe4..5c116f2eefc2514d72052661dd3e0ae6187790c0 100644 (file)
@@ -24,6 +24,7 @@ class SendNotificationEmailJob : public Job
 {
 public:
        explicit SendNotificationEmailJob (std::string body);
 {
 public:
        explicit SendNotificationEmailJob (std::string body);
+       ~SendNotificationEmailJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;
index 11f700de077490751550913257e8991df05f4d8a..d27609f0bdd715aac50fff167e7dbbaf40b2c042 100644 (file)
@@ -52,6 +52,11 @@ SendProblemReportJob::SendProblemReportJob (
 
 }
 
 
 }
 
+SendProblemReportJob::~SendProblemReportJob ()
+{
+       stop_thread ();
+}
+
 string
 SendProblemReportJob::name () const
 {
 string
 SendProblemReportJob::name () const
 {
index c4371a54ed4b32014ed8e1a8afd6355ed692f806..af1a4b26901688efb7a164050d9de09a5acd9bca 100644 (file)
@@ -31,6 +31,8 @@ public:
                std::string summary
                );
 
                std::string summary
                );
 
+       ~SendProblemReportJob ();
+
        std::string name () const;
        std::string json_name () const;
        void run ();
        std::string name () const;
        std::string json_name () const;
        void run ();
index 7fe28d210873abd328b75b212da1154e915731a4..fb586b0825631da9e9a9efc79038103733735791 100644 (file)
@@ -54,9 +54,6 @@ TranscodeJob::TranscodeJob (shared_ptr<const Film> film)
 
 TranscodeJob::~TranscodeJob ()
 {
 
 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 ();
 }
 
        stop_thread ();
 }
 
index b229fddbe217f8d5926a4e94633c33103753dee0..fbfbb92d83459bc1c89189cf3016a5880ad1c273 100644 (file)
@@ -46,6 +46,11 @@ UploadJob::UploadJob (shared_ptr<const Film> film)
 
 }
 
 
 }
 
+UploadJob::~UploadJob ()
+{
+       stop_thread ();
+}
+
 string
 UploadJob::name () const
 {
 string
 UploadJob::name () const
 {
index 407094ab839851fb1b49f0b3801bb4a5530a949c..3a613fd72e4c1c73daed418b33a0811b3d7a761f 100644 (file)
@@ -28,6 +28,7 @@ class UploadJob : public Job
 {
 public:
        explicit UploadJob (boost::shared_ptr<const Film>);
 {
 public:
        explicit UploadJob (boost::shared_ptr<const Film>);
+       ~UploadJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;
index 908cd53a7f14d3ae8ad8665a3874d480ebc1661e..c1dcbc7924f4e8b5de653e8f6d53ef5f00a0faaf 100644 (file)
@@ -36,6 +36,11 @@ VerifyDCPJob::VerifyDCPJob (vector<boost::filesystem::path> directories)
 
 }
 
 
 }
 
+VerifyDCPJob::~VerifyDCPJob ()
+{
+       stop_thread ();
+}
+
 string
 VerifyDCPJob::name () const
 {
 string
 VerifyDCPJob::name () const
 {
index a93a7adfa30ae83231097f619c97acb57f8c33a2..2cff5ab6cd1ffdd934efc030b79e7edff0e12c02 100644 (file)
@@ -28,6 +28,7 @@ class VerifyDCPJob : public Job
 {
 public:
        explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories);
 {
 public:
        explicit VerifyDCPJob (std::vector<boost::filesystem::path> directories);
+       ~VerifyDCPJob ();
 
        std::string name () const;
        std::string json_name () const;
 
        std::string name () const;
        std::string json_name () const;