From: Carl Hetherington Date: Fri, 6 Mar 2020 20:59:58 +0000 (+0000) Subject: Destroy Job threads at the start of the subclass destructors, X-Git-Tag: v2.14.32~4 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=e03d6f9bc6af9dfa8602c82cc52040a92144deaf Destroy Job threads at the start of the subclass destructors, so that the thread is gone before the object is torn down. --- diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index e4a100c4a..611a57f5b 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -82,6 +82,7 @@ AnalyseAudioJob::AnalyseAudioJob (shared_ptr film, shared_ptr (i); } diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index 3d5e4e979..fbeb695df 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -41,6 +41,11 @@ CheckContentChangeJob::CheckContentChangeJob (shared_ptr film, share } +CheckContentChangeJob::~CheckContentChangeJob() +{ + destroy_thread (); +} + string CheckContentChangeJob::name () const { diff --git a/src/lib/check_content_change_job.h b/src/lib/check_content_change_job.h index da9c5cb20..963d09b59 100644 --- a/src/lib/check_content_change_job.h +++ b/src/lib/check_content_change_job.h @@ -28,6 +28,7 @@ class CheckContentChangeJob : public Job { public: CheckContentChangeJob (boost::shared_ptr, boost::shared_ptr following = boost::shared_ptr()); + ~CheckContentChangeJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/examine_content_job.cc b/src/lib/examine_content_job.cc index 86e0a107e..5c854a99b 100644 --- a/src/lib/examine_content_job.cc +++ b/src/lib/examine_content_job.cc @@ -38,6 +38,11 @@ ExamineContentJob::ExamineContentJob (shared_ptr film, shared_ptr, boost::shared_ptr); + ~ExamineContentJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/examine_ffmpeg_subtitles_job.cc b/src/lib/examine_ffmpeg_subtitles_job.cc index b9d5f54e5..eb2cbcd1f 100644 --- a/src/lib/examine_ffmpeg_subtitles_job.cc +++ b/src/lib/examine_ffmpeg_subtitles_job.cc @@ -43,6 +43,11 @@ ExamineFFmpegSubtitlesJob::ExamineFFmpegSubtitlesJob (shared_ptr fil } +ExamineFFmpegSubtitlesJob::~ExamineFFmpegSubtitlesJob () +{ + destroy_thread (); +} + string ExamineFFmpegSubtitlesJob::name () const { diff --git a/src/lib/examine_ffmpeg_subtitles_job.h b/src/lib/examine_ffmpeg_subtitles_job.h index 5960a9cc3..0a0101193 100644 --- a/src/lib/examine_ffmpeg_subtitles_job.h +++ b/src/lib/examine_ffmpeg_subtitles_job.h @@ -28,6 +28,7 @@ class ExamineFFmpegSubtitlesJob : public Job, public FFmpeg { public: ExamineFFmpegSubtitlesJob (boost::shared_ptr, boost::shared_ptr); + ~ExamineFFmpegSubtitlesJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/job.cc b/src/lib/job.cc index 451776524..d4023973c 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -61,6 +61,15 @@ Job::Job (shared_ptr film) } Job::~Job () +{ +#ifdef DCPOMATIC_DEBUG + /* Any subclass should have called destroy_thread in its destructor */ + assert (!_thread); +#endif +} + +void +Job::destroy_thread () { if (_thread) { _thread->interrupt (); @@ -75,6 +84,7 @@ Job::~Job () } delete _thread; + _thread = 0; } /** Start the job in a separate thread, returning immediately */ diff --git a/src/lib/job.h b/src/lib/job.h index 0e57021e0..7047a7ba3 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -112,6 +112,7 @@ protected: void set_message (std::string m); int elapsed_sub_time () const; void check_for_interruption_or_pause (); + void destroy_thread (); boost::shared_ptr _film; diff --git a/src/lib/send_kdm_email_job.cc b/src/lib/send_kdm_email_job.cc index 38484b91e..a4b4b297f 100644 --- a/src/lib/send_kdm_email_job.cc +++ b/src/lib/send_kdm_email_job.cc @@ -53,6 +53,11 @@ SendKDMEmailJob::SendKDMEmailJob ( } +SendKDMEmailJob::~SendKDMEmailJob () +{ + destroy_thread (); +} + string SendKDMEmailJob::name () const { diff --git a/src/lib/send_kdm_email_job.h b/src/lib/send_kdm_email_job.h index b4e007e3b..fcb9a0b9e 100644 --- a/src/lib/send_kdm_email_job.h +++ b/src/lib/send_kdm_email_job.h @@ -38,6 +38,8 @@ public: std::string cpl_name ); + ~SendKDMEmailJob (); + std::string name () const; std::string json_name () const; void run (); diff --git a/src/lib/send_notification_email_job.cc b/src/lib/send_notification_email_job.cc index abbb844e2..5986e5a16 100644 --- a/src/lib/send_notification_email_job.cc +++ b/src/lib/send_notification_email_job.cc @@ -40,6 +40,11 @@ SendNotificationEmailJob::SendNotificationEmailJob (string body) } +SendNotificationEmailJob::~SendNotificationEmailJob () +{ + destroy_thread (); +} + string SendNotificationEmailJob::name () const { diff --git a/src/lib/send_notification_email_job.h b/src/lib/send_notification_email_job.h index 04f1d98ab..5c116f2ee 100644 --- a/src/lib/send_notification_email_job.h +++ b/src/lib/send_notification_email_job.h @@ -24,6 +24,7 @@ class SendNotificationEmailJob : public Job { public: explicit SendNotificationEmailJob (std::string body); + ~SendNotificationEmailJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/send_problem_report_job.cc b/src/lib/send_problem_report_job.cc index 11f700de0..83092049f 100644 --- a/src/lib/send_problem_report_job.cc +++ b/src/lib/send_problem_report_job.cc @@ -52,6 +52,11 @@ SendProblemReportJob::SendProblemReportJob ( } +SendProblemReportJob::~SendProblemReportJob () +{ + destroy_thread (); +} + string SendProblemReportJob::name () const { diff --git a/src/lib/send_problem_report_job.h b/src/lib/send_problem_report_job.h index c4371a54e..af1a4b269 100644 --- a/src/lib/send_problem_report_job.h +++ b/src/lib/send_problem_report_job.h @@ -31,6 +31,8 @@ public: std::string summary ); + ~SendProblemReportJob (); + std::string name () const; std::string json_name () const; void run (); diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 1db37e370..f2711bf17 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -51,6 +51,11 @@ TranscodeJob::TranscodeJob (shared_ptr film) } +TranscodeJob::~TranscodeJob () +{ + destroy_thread (); +} + string TranscodeJob::name () const { diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h index 9dd9e3684..fccb1a44a 100644 --- a/src/lib/transcode_job.h +++ b/src/lib/transcode_job.h @@ -34,6 +34,7 @@ class TranscodeJob : public Job { public: explicit TranscodeJob (boost::shared_ptr film); + ~TranscodeJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/upload_job.cc b/src/lib/upload_job.cc index b229fddbe..eca46838d 100644 --- a/src/lib/upload_job.cc +++ b/src/lib/upload_job.cc @@ -46,6 +46,11 @@ UploadJob::UploadJob (shared_ptr film) } +UploadJob::~UploadJob () +{ + destroy_thread (); +} + string UploadJob::name () const { diff --git a/src/lib/upload_job.h b/src/lib/upload_job.h index 407094ab8..3a613fd72 100644 --- a/src/lib/upload_job.h +++ b/src/lib/upload_job.h @@ -28,6 +28,7 @@ class UploadJob : public Job { public: explicit UploadJob (boost::shared_ptr); + ~UploadJob (); std::string name () const; std::string json_name () const; diff --git a/src/lib/verify_dcp_job.cc b/src/lib/verify_dcp_job.cc index 5fb2a59c1..03d9c4c4c 100644 --- a/src/lib/verify_dcp_job.cc +++ b/src/lib/verify_dcp_job.cc @@ -35,6 +35,11 @@ VerifyDCPJob::VerifyDCPJob (vector directories) } +VerifyDCPJob::~VerifyDCPJob () +{ + destroy_thread (); +} + string VerifyDCPJob::name () const { diff --git a/src/lib/verify_dcp_job.h b/src/lib/verify_dcp_job.h index a93a7adfa..2cff5ab6c 100644 --- a/src/lib/verify_dcp_job.h +++ b/src/lib/verify_dcp_job.h @@ -28,6 +28,7 @@ class VerifyDCPJob : public Job { public: explicit VerifyDCPJob (std::vector directories); + ~VerifyDCPJob (); std::string name () const; std::string json_name () const;