X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fjob.cc;h=8966a65e700eb84b8f3945eb7d81987d8c88f7b5;hp=7539a50703faa2074375bbf17ff7639509a7ddc5;hb=386e25f3b9d3fa59cbdeed458d9b3e0d21e338b8;hpb=ec97893127a2d59871d92c9e658b6b1ab3100b40 diff --git a/src/lib/job.cc b/src/lib/job.cc index 7539a5070..8966a65e7 100644 --- a/src/lib/job.cc +++ b/src/lib/job.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington + Copyright (C) 2012-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -28,6 +28,7 @@ #include "exceptions.h" #include "film.h" #include "log.h" +#include "dcpomatic_log.h" #include "compose.hpp" #include #include @@ -45,9 +46,7 @@ using std::cout; using boost::shared_ptr; using boost::optional; using boost::function; - -#define LOG_ERROR_NC(...) if (_film) { _film->log()->log (__VA_ARGS__, LogEntry::TYPE_ERROR); } -#define LOG_GENERAL(...) if (_film) { _film->log()->log (String::compose (__VA_ARGS__), LogEntry::TYPE_GENERAL); } +using namespace dcpomatic; /** @param film Associated film, or 0 */ Job::Job (shared_ptr film) @@ -63,6 +62,12 @@ Job::Job (shared_ptr film) } Job::~Job () +{ + stop_thread (); +} + +void +Job::stop_thread () { if (_thread) { _thread->interrupt (); @@ -77,6 +82,7 @@ Job::~Job () } delete _thread; + _thread = 0; } /** Start the job in a separate thread, returning immediately */ @@ -186,6 +192,12 @@ Job::run_wrapper () set_progress (1); set_state (FINISHED_ERROR); + } catch (FileError& e) { + + set_error (e.what(), e.what()); + set_progress (1); + set_state (FINISHED_ERROR); + } catch (std::exception& e) { set_error ( @@ -290,6 +302,7 @@ Job::set_state (State s) if (finished) { emit (boost::bind (boost::ref (Finished))); + FinishedImmediate (); } } @@ -444,7 +457,7 @@ Job::status () const if (now.date() != finish.date()) { /// TRANSLATORS: the %1 in this string will be filled in with a day of the week /// to say what day a job will finish. - day = String::compose (_(" on %1"), finish.date().day_of_week().as_long_string()); + day = String::compose (_(" on %1"), day_of_week_to_string(finish.date().day_of_week())); } /// TRANSLATORS: "remaining; finishing at" here follows an amount of time that is remaining /// on an operation; after it is an estimated wall-clock completion time.