summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-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 ()