From 0ec7c9d0b1f3ea58ffe17dd70bea04ad702d164b Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 1 Sep 2015 21:04:15 +0100 Subject: Tidy up thread in destructor (Job) --- src/lib/job.cc | 10 ++++++++++ src/lib/job.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/job.cc b/src/lib/job.cc index 87e4fb3d3..784defc91 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -53,6 +53,16 @@ Job::Job (shared_ptr film) } +Job::~Job () +{ + if (_thread) { + _thread->interrupt (); + _thread->join (); + } + + delete _thread; +} + /** Start the job in a separate thread, returning immediately */ void Job::start () diff --git a/src/lib/job.h b/src/lib/job.h index 4e52e76a1..1caa5a904 100644 --- a/src/lib/job.h +++ b/src/lib/job.h @@ -40,7 +40,7 @@ class Job : public boost::enable_shared_from_this, public Signaller, public { public: Job (boost::shared_ptr); - virtual ~Job() {} + virtual ~Job (); /** @return user-readable name of this job */ virtual std::string name () const = 0; -- cgit v1.2.3