Fix job ordering when sending notification emails (more of #1286).
authorCarl Hetherington <cth@carlh.net>
Mon, 28 May 2018 23:56:25 +0000 (00:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 28 May 2018 23:56:25 +0000 (00:56 +0100)
src/lib/job_manager.cc
src/lib/job_manager.h
src/wx/job_view.cc

index e3b6e257b4f4a9bb05c7b9e3e2815de9570d5d4a..6d651d2ba1d51adc531efc64b51c6c5f88002d31 100644 (file)
@@ -90,6 +90,21 @@ JobManager::add (shared_ptr<Job> j)
        return j;
 }
 
+shared_ptr<Job>
+JobManager::add_after (shared_ptr<Job> after, shared_ptr<Job> j)
+{
+       {
+               boost::mutex::scoped_lock lm (_mutex);
+               list<shared_ptr<Job> >::iterator i = find (_jobs.begin(), _jobs.end(), after);
+               DCPOMATIC_ASSERT (i != _jobs.end());
+               _jobs.insert (i, j);
+       }
+
+       emit (boost::bind (boost::ref (JobAdded), weak_ptr<Job> (j)));
+
+       return j;
+}
+
 list<shared_ptr<Job> >
 JobManager::get () const
 {
index 9cba0fd094a46bd44796532543e6e7ac9ebce4ac..a382dd7363732cc4ddd20fad782005bd438ea2ff 100644 (file)
@@ -41,6 +41,7 @@ class JobManager : public Signaller, public boost::noncopyable
 {
 public:
        boost::shared_ptr<Job> add (boost::shared_ptr<Job>);
+       boost::shared_ptr<Job> add_after (boost::shared_ptr<Job> after, boost::shared_ptr<Job> j);
        std::list<boost::shared_ptr<Job> > get () const;
        bool work_to_do () const;
        bool errors () const;
index d0086ff81aae2acbbe332164f36489355b5f9a0f..43d6f2fedd9ca90f44d4ec3e191fb673af560f2f 100644 (file)
@@ -142,7 +142,7 @@ JobView::finished ()
                        string body = Config::instance()->notification_email();
                        boost::algorithm::replace_all (body, "$JOB_NAME", _job->name());
                        boost::algorithm::replace_all (body, "$JOB_STATUS", _job->status());
-                       JobManager::instance()->add (shared_ptr<Job> (new SendNotificationEmailJob (body)));
+                       JobManager::instance()->add_after (_job, shared_ptr<Job> (new SendNotificationEmailJob (body)));
                }
        }
 }