summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-09-01 19:51:53 +0100
committerCarl Hetherington <cth@carlh.net>2015-09-01 19:51:53 +0100
commita16f2c07ea7301ed1b82b9039ea7db7c025054ff (patch)
treec3cedad2e9f8634e5f6fec8836f0ea0c55f02b09 /src
parent78d8f1166fb0f8f8cee7996e3c9b7f5d088f72df (diff)
Fix crash on cancellation of encodes during check of image data; allow cancellation during this time (#679).
Diffstat (limited to 'src')
-rw-r--r--src/lib/job.cc12
-rw-r--r--src/lib/job.h1
-rw-r--r--src/lib/writer.cc9
3 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/job.cc b/src/lib/job.cc
index d9715aa18..87e4fb3d3 100644
--- a/src/lib/job.cc
+++ b/src/lib/job.cc
@@ -247,6 +247,12 @@ Job::set_progress (float p, bool force)
return;
}
+ set_progress_common (p);
+}
+
+void
+Job::set_progress_common (optional<float> p)
+{
boost::mutex::scoped_lock lm (_progress_mutex);
_progress = p;
boost::this_thread::interruption_point ();
@@ -315,11 +321,7 @@ Job::set_error (string s, string d)
void
Job::set_progress_unknown ()
{
- boost::mutex::scoped_lock lm (_progress_mutex);
- _progress.reset ();
- lm.unlock ();
-
- emit (boost::bind (boost::ref (Progress)));
+ set_progress_common (optional<float> ());
}
/** @return Human-readable status of this job */
diff --git a/src/lib/job.h b/src/lib/job.h
index 06a341f40..4e52e76a1 100644
--- a/src/lib/job.h
+++ b/src/lib/job.h
@@ -106,6 +106,7 @@ protected:
private:
void run_wrapper ();
+ void set_progress_common (boost::optional<float> p);
boost::thread* _thread;
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 58b2b8a91..9c4a194e8 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -147,9 +147,14 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
throw InvalidSignerError ();
}
- _thread = new boost::thread (boost::bind (&Writer::thread, this));
-
job->sub (_("Encoding image data"));
+
+ /* Do this last; if something after this line were to throw an exception
+ (say if Job::sub was interrupted by cancel) this thread would never
+ get properly cleaned up but the Writer object would go away underneath
+ it.
+ */
+ _thread = new boost::thread (boost::bind (&Writer::thread, this));
}
Writer::~Writer ()