summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-07-23 14:26:02 +0100
committerCarl Hetherington <cth@carlh.net>2019-07-23 14:26:02 +0100
commitbf19399f8c009ff211d5c7b45b0941417d963c4e (patch)
tree3461fb9045462aec4c01de8d5d34f4a73e755b96 /src
parentf737005941d25e5e5743a6770208f31bdca5527d (diff)
Tidy up handling of content-modified checks when using the dcpomatic_cli.
Diffstat (limited to 'src')
-rw-r--r--src/lib/check_content_change_job.cc32
-rw-r--r--src/lib/check_content_change_job.h3
-rw-r--r--src/lib/film.cc4
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/util.cc25
-rw-r--r--src/tools/dcpomatic.cc2
-rw-r--r--src/tools/dcpomatic_cli.cc2
7 files changed, 37 insertions, 33 deletions
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<const Film> film, shared_ptr<Job> following)
+/** @param gui true if we are running this job from the GUI, false if it's the CLI */
+CheckContentChangeJob::CheckContentChangeJob (shared_ptr<const Film> film, shared_ptr<Job> following, bool gui)
: Job (film)
, _following (following)
+ , _gui (gui)
{
}
@@ -79,18 +81,28 @@ CheckContentChangeJob::run ()
JobManager::instance()->add(shared_ptr<Job>(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<const Film>, boost::shared_ptr<Job> following = boost::shared_ptr<Job>());
+ CheckContentChangeJob (boost::shared_ptr<const Film>, boost::shared_ptr<Job> following = boost::shared_ptr<Job>(), bool gui = false);
std::string name () const;
std::string json_name () const;
@@ -35,4 +35,5 @@ public:
private:
boost::shared_ptr<Job> _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<const Playlist> 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<TranscodeJob> tj (new TranscodeJob (shared_from_this()));
tj->set_encoder (shared_ptr<Encoder> (new DCPEncoder (shared_from_this(), tj)));
- shared_ptr<CheckContentChangeJob> cc (new CheckContentChangeJob (shared_from_this(), tj));
+ shared_ptr<CheckContentChangeJob> 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 Playlist>) 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<Job> 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) {