Destory TranscodeJob earlier, hopefully to fix #1570.
authorCarl Hetherington <cth@carlh.net>
Thu, 30 May 2019 19:08:39 +0000 (20:08 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 30 May 2019 19:08:39 +0000 (20:08 +0100)
src/lib/job.cc
src/lib/job.h
src/lib/transcode_job.cc
src/lib/transcode_job.h

index 1416ddfc20c4d1906b785a67ddc8506d40894b17..43b5fb7e13f50d3672eac81434b0a9e2409f5ee6 100644 (file)
@@ -62,6 +62,12 @@ Job::Job (shared_ptr<const Film> 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 */
index 0e57021e0c1cafbcc545c2502a94d7462f2c9834..cb85059a61875c470a5a750d225fe51930dd7ee2 100644 (file)
@@ -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<const Film> _film;
 
index 356e862e0c87bb14de9d00d4ff7a6935abdfc5b2..981816fd528f24edc19e071cf37526c88f37b714 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -51,6 +51,14 @@ 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 ();
+}
+
 string
 TranscodeJob::name () const
 {
index 9dd9e36846abf5036fc894c743eb717585dfece2..8240977b9e1de83be715db8e339c9ff0fcbf5058 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -34,6 +34,7 @@ class TranscodeJob : public Job
 {
 public:
        explicit TranscodeJob (boost::shared_ptr<const Film> film);
+       ~TranscodeJob ();
 
        std::string name () const;
        std::string json_name () const;