From: Carl Hetherington Date: Thu, 30 May 2019 19:08:39 +0000 (+0100) Subject: Destory TranscodeJob earlier, hopefully to fix #1570. X-Git-Tag: v2.15.6~24^2 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=9b98a07cb61fd66fd73f9f58468100ec9b7eddd3 Destory TranscodeJob earlier, hopefully to fix #1570. --- diff --git a/src/lib/job.cc b/src/lib/job.cc index 1416ddfc2..43b5fb7e1 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -62,6 +62,12 @@ Job::Job (shared_ptr film) } Job::~Job () +{ + stop_thread (); +} + +void +Job::stop_thread () { if (_thread) { _thread->interrupt (); @@ -76,6 +82,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..cb85059a6 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 stop_thread (); boost::shared_ptr _film; diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc index 356e862e0..981816fd5 100644 --- a/src/lib/transcode_job.cc +++ b/src/lib/transcode_job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -51,6 +51,14 @@ TranscodeJob::TranscodeJob (shared_ptr 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 (); +} + string TranscodeJob::name () const { diff --git a/src/lib/transcode_job.h b/src/lib/transcode_job.h index 9dd9e3684..8240977b9 100644 --- a/src/lib/transcode_job.h +++ b/src/lib/transcode_job.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -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;