Merge branch 'master' of /home/carl/git/dvdomatic
[dcpomatic.git] / src / lib / job.cc
index e78a9131581e6183ceefc2fb96ac20a4b28f421e..d3871bf7225da22ed1911416c1b2ee4df4cffd5d 100644 (file)
@@ -34,10 +34,11 @@ using namespace boost;
  *  @param o Options.
  *  @param l A log that we can write to.
  */
-Job::Job (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l)
+Job::Job (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
        : _fs (s)
        , _opt (o)
        , _log (l)
+       , _required (req)
        , _state (NEW)
        , _start_time (0)
        , _progress_unknown (false)
@@ -69,9 +70,7 @@ Job::run_wrapper ()
                
                set_progress (1);
                set_state (FINISHED_ERROR);
-               stringstream s;
-               s << e.what() << "(" << filesystem::path (e.filename()).leaf() << ")";
-               set_error (s.str ());
+               set_error (String::compose ("%1 (%2)", e.what(), filesystem::path (e.filename()).leaf()));
                
        } catch (std::exception& e) {
 
@@ -82,6 +81,13 @@ Job::run_wrapper ()
        }
 }
 
+bool
+Job::is_new () const
+{
+       boost::mutex::scoped_lock lm (_state_mutex);
+       return _state == NEW;
+}
+
 /** @return true if the job is running */
 bool
 Job::running () const