BOOST_FOREACH.
[dcpomatic.git] / src / lib / job.cc
index a83249e798feba99abafc2a09f1393eb8cf5dc18..f0d8fcbbc1d4554dc920924cfdae43bdb0f4c01a 100644 (file)
@@ -34,7 +34,6 @@
 #include <sub/exceptions.h>
 #include <boost/thread.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <iostream>
 
@@ -43,7 +42,7 @@
 using std::string;
 using std::list;
 using std::cout;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
 using boost::function;
 using namespace dcpomatic;
@@ -71,16 +70,12 @@ Job::~Job ()
 void
 Job::stop_thread ()
 {
-       if (!_thread.joinable()) {
-               return;
-       }
+       boost::this_thread::disable_interruption dis;
 
        _thread.interrupt ();
        try {
                _thread.join ();
-       } catch (...) {
-               /* Too late to do anything about this */
-       }
+       } catch (...) {}
 }
 
 /** Start the job in a separate thread, returning immediately */
@@ -122,6 +117,42 @@ Job::run_wrapper ()
                set_progress (1);
                set_state (FINISHED_ERROR);
 
+       } catch (dcp::StartCompressionError& e) {
+
+               bool done = false;
+
+#ifdef DCPOMATIC_WINDOWS
+#if (__GNUC__ && !__x86_64__)
+               /* 32-bit */
+               set_error (
+                       _("Failed to encode the DCP."),
+                       _("This error has probably occurred because you are running the 32-bit version of DCP-o-matic and "
+                         "trying to use too many encoding threads.  Please reduce the 'number of threads DCP-o-matic should "
+                         "use' in the General tab of Preferences and try again.")
+                       );
+               done = true;
+#else
+               /* 64-bit */
+               if (running_32_on_64()) {
+                       set_error (
+                               _("Failed to encode the DCP."),
+                               _("This error has probably occurred because you are running the 32-bit version of DCP-o-matic.  Please re-install DCP-o-matic with the 64-bit installer and try again.")
+                               );
+                       done = true;
+               }
+#endif
+#endif
+
+               if (!done) {
+                       set_error (
+                               e.what (),
+                               string (_("It is not known what caused this error.")) + "  " + REPORT_PROBLEM
+                               );
+               }
+
+               set_progress (1);
+               set_state (FINISHED_ERROR);
+
        } catch (OpenFileError& e) {
 
                set_error (
@@ -164,7 +195,7 @@ Job::run_wrapper ()
        } catch (sub::SubripError& e) {
 
                string extra = "Error is near:\n";
-               BOOST_FOREACH (string i, e.context()) {
+               for (auto i: e.context()) {
                        extra += i + "\n";
                }
 
@@ -178,7 +209,7 @@ Job::run_wrapper ()
                set_progress (1);
                set_state (FINISHED_ERROR);
 
-       } catch (dcp::DCPReadError& e) {
+       } catch (dcp::ReadError& e) {
 
                set_error (e.message(), e.detail().get_value_or(""));
                set_progress (1);