Fix erroneous optional dereference.
[dcpomatic.git] / src / lib / job.cc
index c4632a83c6e9e9dbb036de90a3598d2abe5cd02e..7aaac748c115a1d9e65144027e7eacf96f1d6640 100644 (file)
@@ -59,6 +59,7 @@ Job::~Job ()
 {
        if (_thread) {
                _thread->interrupt ();
+               DCPOMATIC_ASSERT (_thread->joinable ());
                _thread->join ();
        }
 
@@ -133,7 +134,7 @@ Job::run_wrapper ()
 
        } catch (std::bad_alloc& e) {
 
-               set_error (_("Out of memory"), _("There was not enough memory to do this."));
+               set_error (_("Out of memory"), _("There was not enough memory to do this.  If you are running a 32-bit operating system try reducing the number of encoding threads in the General tab of Preferences."));
                set_progress (1);
                set_state (FINISHED_ERROR);
 
@@ -416,7 +417,10 @@ Job::cancel ()
        }
 
        _thread->interrupt ();
+       DCPOMATIC_ASSERT (_thread->joinable ());
        _thread->join ();
+       delete _thread;
+       _thread = 0;
 }
 
 void
@@ -447,4 +451,3 @@ Job::when_finished (boost::signals2::connection& connection, function<void()> fi
                connection = Finished.connect (finished);
        }
 }
-