No-op: remove all trailing whitespace.
[dcpomatic.git] / src / lib / job.cc
index f281466325f8c34a7e78d8e0ad8229910335946b..71e4c34464be7db3eec2db19dbd8b0c5fa31a454 100644 (file)
@@ -27,7 +27,6 @@
 #include "job.h"
 #include "util.h"
 #include "cross.h"
-#include "ui_signaller.h"
 #include "exceptions.h"
 #include "film.h"
 #include "log.h"
@@ -42,8 +41,8 @@ using boost::optional;
 
 #define LOG_ERROR_NC(...) _film->log()->log (__VA_ARGS__, Log::TYPE_ERROR);
 
-Job::Job (shared_ptr<const Film> f)
-       : _film (f)
+Job::Job (shared_ptr<const Film> film)
+       : _film (film)
        , _thread (0)
        , _state (NEW)
        , _start_time (0)
@@ -87,7 +86,7 @@ Job::run_wrapper ()
                set_error (e.what(), m);
                set_progress (1);
                set_state (FINISHED_ERROR);
-               
+
        } catch (OpenFileError& e) {
 
                set_error (
@@ -107,7 +106,7 @@ Job::run_wrapper ()
                set_error (_("Out of memory"), _("There was not enough memory to do this."));
                set_progress (1);
                set_state (FINISHED_ERROR);
-               
+
        } catch (std::exception& e) {
 
                set_error (
@@ -117,7 +116,7 @@ Job::run_wrapper ()
 
                set_progress (1);
                set_state (FINISHED_ERROR);
-               
+
        } catch (...) {
 
                set_error (
@@ -183,7 +182,7 @@ Job::paused () const
        boost::mutex::scoped_lock lm (_state_mutex);
        return _state == PAUSED;
 }
-       
+
 /** Set the state of this job.
  *  @param s New state.
  */
@@ -205,7 +204,7 @@ Job::set_state (State s)
 
        if (finished) {
                emit (boost::bind (boost::ref (Finished)));
-       }       
+       }
 }
 
 /** @return DCPTime (in seconds) that this sub-job has been running */
@@ -215,7 +214,7 @@ Job::elapsed_time () const
        if (_start_time == 0) {
                return 0;
        }
-       
+
        return time (0) - _start_time;
 }
 
@@ -239,6 +238,9 @@ Job::set_progress (float p, bool force)
                _pause_changed.wait (lm2);
        }
 
+       lm.unlock ();
+       lm2.unlock ();
+
        emit (boost::bind (boost::ref (Progress)));
 }
 
@@ -257,7 +259,7 @@ Job::sub (string n)
                boost::mutex::scoped_lock lm (_progress_mutex);
                _sub_name = n;
        }
-       
+
        set_progress (0, true);
 }
 
@@ -284,7 +286,7 @@ Job::set_error (string s, string 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;
@@ -317,9 +319,9 @@ Job::status () const
                        /* 100% makes it sound like we've finished when we haven't */
                        pc = 99;
                }
-               
+
                s << pc << N_("%");
-               
+
                if (t > 10 && r > 0) {
                        /// TRANSLATORS: remaining here follows an amount of time that is remaining
                        /// on an operation.
@@ -366,7 +368,7 @@ Job::remaining_time () const
        if (progress().get_value_or(0) == 0) {
                return elapsed_time ();
        }
-       
+
        return elapsed_time() / progress().get() - elapsed_time();
 }
 
@@ -377,6 +379,10 @@ Job::cancel ()
                return;
        }
 
+       if (paused ()) {
+               resume ();
+       }
+
        _thread->interrupt ();
        _thread->join ();
 }