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)
{
}
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);
}
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;
private:
boost::shared_ptr<Job> _following;
+ bool _gui;
};
/** 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"));
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);
}
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.
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);
first = false;
- int unfinished = 0;
- int finished_in_error = 0;
-
BOOST_FOREACH (shared_ptr<Job> i, jobs) {
if (progress) {
cout << i->name();
}
}
- 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;
}
}
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) {
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) {