diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-12-07 00:02:25 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-12-08 13:13:08 +0100 |
| commit | 7d1fb4361e6eec27c9eefb886761293e904f0dff (patch) | |
| tree | 41d2b6de168a437d9ec7fba7f4f00ad0046f56df /src/lib | |
| parent | 613b06aa87ae10517409a9a376e294c2c2d2a9bf (diff) | |
Make Writer tolerate a nullptr Job.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/writer.cc | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/writer.cc b/src/lib/writer.cc index ca0a570e7..f7d3bcd25 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -70,6 +70,16 @@ using dcp::Data; using dcp::ArrayData; using namespace dcpomatic; + +static +void +ignore_progress (float) +{ + +} + + +/** @param j Job to report progress to, or 0 */ Writer::Writer (weak_ptr<const Film> weak_film, weak_ptr<Job> j) : WeakConstFilm (weak_film) , _job (j) @@ -84,7 +94,6 @@ Writer::Writer (weak_ptr<const Film> weak_film, weak_ptr<Job> j) , _pushed_to_disk (0) { shared_ptr<Job> job = _job.lock (); - DCPOMATIC_ASSERT (job); int reel_index = 0; list<DCPTimePeriod> const reels = film()->reels(); @@ -541,7 +550,9 @@ Writer::finish () /* Calculate digests for each reel in parallel */ shared_ptr<Job> job = _job.lock (); - job->sub (_("Computing digests")); + if (job) { + job->sub (_("Computing digests")); + } boost::asio::io_service service; boost::thread_group pool; @@ -554,7 +565,13 @@ Writer::finish () pool.create_thread (boost::bind (&boost::asio::io_service::run, &service)); } - boost::function<void (float)> set_progress = boost::bind (&Writer::set_digest_progress, this, job.get(), _1); + boost::function<void (float)> set_progress; + if (job) { + set_progress = boost::bind (&Writer::set_digest_progress, this, job.get(), _1); + } else { + set_progress = &ignore_progress; + } + BOOST_FOREACH (ReelWriter& i, _reels) { service.post (boost::bind (&ReelWriter::calculate_digests, &i, set_progress)); } |
