X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fjob.cc;h=5b0b9c6044475a0b11c5e84318b09df409c60908;hb=4dbc6ef917aeceb906b1ef1caf6911033e7e2c54;hp=c6a6b90a808fcdd234c053ce1c21a31d3128d3eb;hpb=308488324dbc4d8b709d3fb1dc9fee0479346c21;p=dcpomatic.git diff --git a/src/lib/job.cc b/src/lib/job.cc index c6a6b90a8..5b0b9c604 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -37,9 +37,10 @@ using std::string; using std::list; using std::cout; -using std::stringstream; using boost::shared_ptr; +#define LOG_ERROR_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_ERROR); + Job::Job (shared_ptr f) : _film (f) , _thread (0) @@ -110,7 +111,7 @@ Job::run_wrapper () set_error ( e.what (), - _("It is not known what caused this error. Please report the problem to the DCP-o-matic author (carl@dcpomatic.com).") + string (_("It is not known what caused this error.")) + " " + REPORT_PROBLEM ); set_progress (1); @@ -120,7 +121,7 @@ Job::run_wrapper () set_error ( _("Unknown error"), - _("It is not known what caused this error. Please report the problem to the DCP-o-matic author (carl@dcpomatic.com).") + string (_("It is not known what caused this error.")) + " " + REPORT_PROBLEM ); set_progress (1); @@ -232,8 +233,9 @@ Job::set_progress (float p, bool force) _progress = p; boost::this_thread::interruption_point (); - if (paused ()) { - dcpomatic_sleep (1); + boost::mutex::scoped_lock lm2 (_state_mutex); + while (_state == PAUSED) { + _pause_changed.wait (lm2); } if (ui_signaller) { @@ -281,7 +283,10 @@ Job::error_summary () const void Job::set_error (string s, string d) { - _film->log()->log (String::compose ("Error in job: %1 (%2)", s, d)); + LOG_ERROR_NC (s); + LOG_ERROR_NC (d); + + _film->log()->log (String::compose ("Error in job: %1 (%2)", s, d), Log::TYPE_ERROR); boost::mutex::scoped_lock lm (_state_mutex); _error_summary = s; _error_details = d; @@ -309,7 +314,7 @@ Job::status () const pc = 99; } - stringstream s; + SafeStringStream s; if (!finished ()) { s << pc << N_("%"); if (p >= 0 && t > 10 && r > 0) { @@ -328,29 +333,6 @@ Job::status () const return s.str (); } -string -Job::json_status () const -{ - boost::mutex::scoped_lock lm (_state_mutex); - - switch (_state) { - case NEW: - return N_("new"); - case RUNNING: - return N_("running"); - case PAUSED: - return N_("paused"); - case FINISHED_OK: - return N_("finished_ok"); - case FINISHED_ERROR: - return N_("finished_error"); - case FINISHED_CANCELLED: - return N_("finished_cancelled"); - } - - return ""; -} - /** @return An estimate of the remaining time for this sub-job, in seconds */ int Job::remaining_time () const @@ -374,6 +356,7 @@ Job::pause () { if (running ()) { set_state (PAUSED); + _pause_changed.notify_all (); } } @@ -382,5 +365,6 @@ Job::resume () { if (paused ()) { set_state (RUNNING); + _pause_changed.notify_all (); } }