From: Carl Hetherington Date: Tue, 23 Jul 2019 13:26:02 +0000 (+0100) Subject: Tidy up handling of content-modified checks when using the dcpomatic_cli. X-Git-Tag: v2.15.15~14 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=bf19399f8c009ff211d5c7b45b0941417d963c4e Tidy up handling of content-modified checks when using the dcpomatic_cli. --- diff --git a/src/lib/check_content_change_job.cc b/src/lib/check_content_change_job.cc index 468933ae4..2bc562f57 100644 --- a/src/lib/check_content_change_job.cc +++ b/src/lib/check_content_change_job.cc @@ -33,9 +33,11 @@ using std::list; using std::cout; using boost::shared_ptr; -CheckContentChangeJob::CheckContentChangeJob (shared_ptr film, shared_ptr following) +/** @param gui true if we are running this job from the GUI, false if it's the CLI */ +CheckContentChangeJob::CheckContentChangeJob (shared_ptr film, shared_ptr following, bool gui) : Job (film) , _following (following) + , _gui (gui) { } @@ -79,18 +81,28 @@ CheckContentChangeJob::run () JobManager::instance()->add(shared_ptr(new ExamineContentJob(_film, i))); } - set_progress (1); - set_state (FINISHED_OK); - if (!changed.empty()) { - string m = _("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings."); - if (_following) { - /* I'm assuming that _following is a make DCP job */ - m += " "; - m += _("Choose 'Make DCP' again when you have done this."); + if (_gui) { + string m = _("Some files have been changed since they were added to the project.\n\nThese files will now be re-examined, so you may need to check their settings."); + if (_following) { + /* I'm assuming that _following is a make DCP job */ + m += " "; + m += _("Choose 'Make DCP' again when you have done this."); + } + set_message (m); + } else { + set_progress (1); + set_state (FINISHED_ERROR); + set_error ( + _("Some files have been changed since they were added to the project. Open the project in DCP-o-matic, check the settings, then save it before trying again."), + "" + ); + return; } - set_message (m); } else if (_following) { JobManager::instance()->add (_following); } + + set_progress (1); + set_state (FINISHED_OK); } diff --git a/src/lib/check_content_change_job.h b/src/lib/check_content_change_job.h index da9c5cb20..5d0af6881 100644 --- a/src/lib/check_content_change_job.h +++ b/src/lib/check_content_change_job.h @@ -27,7 +27,7 @@ class CheckContentChangeJob : public Job { public: - CheckContentChangeJob (boost::shared_ptr, boost::shared_ptr following = boost::shared_ptr()); + CheckContentChangeJob (boost::shared_ptr, boost::shared_ptr following = boost::shared_ptr(), bool gui = false); std::string name () const; std::string json_name () const; @@ -35,4 +35,5 @@ public: private: boost::shared_ptr _following; + bool _gui; }; diff --git a/src/lib/film.cc b/src/lib/film.cc index e54268805..687033908 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -299,7 +299,7 @@ Film::audio_analysis_path (shared_ptr playlist) const /** Add suitable Jobs to the JobManager to create a DCP for this Film */ void -Film::make_dcp () +Film::make_dcp (bool gui) { if (dcp_name().find ("/") != string::npos) { throw BadSettingError (_("name"), _("Cannot contain slashes")); @@ -353,7 +353,7 @@ Film::make_dcp () shared_ptr tj (new TranscodeJob (shared_from_this())); tj->set_encoder (shared_ptr (new DCPEncoder (shared_from_this(), tj))); - shared_ptr cc (new CheckContentChangeJob (shared_from_this(), tj)); + shared_ptr cc (new CheckContentChangeJob(shared_from_this(), tj, gui)); JobManager::instance()->add (cc); } diff --git a/src/lib/film.h b/src/lib/film.h index 876d312ae..1c5022428 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -82,7 +82,7 @@ public: boost::filesystem::path audio_analysis_path (boost::shared_ptr) const; void send_dcp_to_tms (); - void make_dcp (); + void make_dcp (bool gui = false); /** @return Logger. * It is safe to call this from any thread. diff --git a/src/lib/util.cc b/src/lib/util.cc index 3b6be6dcc..fee4a3c26 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -949,10 +949,9 @@ emit_subtitle_image (ContentTimePeriod period, dcp::SubtitleImage sub, dcp::Size bool show_jobs_on_console (bool progress) { - bool should_stop = false; bool first = true; bool error = false; - while (!should_stop) { + while (true) { dcpomatic_sleep (5); @@ -967,9 +966,6 @@ show_jobs_on_console (bool progress) first = false; - int unfinished = 0; - int finished_in_error = 0; - BOOST_FOREACH (shared_ptr i, jobs) { if (progress) { cout << i->name(); @@ -985,25 +981,20 @@ show_jobs_on_console (bool progress) } } - if (!i->finished ()) { - ++unfinished; - } - - if (i->finished_in_error ()) { - ++finished_in_error; - error = true; - } - - if (!progress && i->finished_in_error ()) { + if (!progress && i->finished_in_error()) { /* We won't see this error if we haven't been showing progress, so show it now. */ cout << i->status() << "\n"; } + + if (i->finished_in_error()) { + error = true; + } } - if (unfinished == 0 || finished_in_error != 0) { - should_stop = true; + if (!JobManager::instance()->work_to_do()) { + break; } } diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 5b2e1870b..572a5be40 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -757,7 +757,7 @@ private: a long time, and crashes/power failures are moderately likely. */ _film->write_metadata (); - _film->make_dcp (); + _film->make_dcp (true); } catch (BadSettingError& e) { error_dialog (this, wxString::Format (_("Bad setting for %s."), std_to_wx(e.setting()).data()), std_to_wx(e.what())); } catch (std::exception& e) { diff --git a/src/tools/dcpomatic_cli.cc b/src/tools/dcpomatic_cli.cc index 9388112f6..13efb6b19 100644 --- a/src/tools/dcpomatic_cli.cc +++ b/src/tools/dcpomatic_cli.cc @@ -349,7 +349,7 @@ main (int argc, char* argv[]) cout << "\nMaking DCP for " << film->name() << "\n"; } - film->make_dcp (); + film->make_dcp (false); bool const error = show_jobs_on_console (progress); if (keep_going) {