Fix display of progress meter (and crash) when sending emails from the KDM
authorCarl Hetherington <cth@carlh.net>
Mon, 6 Feb 2017 10:37:31 +0000 (10:37 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 6 Feb 2017 13:23:54 +0000 (13:23 +0000)
creator (#1045).

ChangeLog
src/wx/job_view.cc
src/wx/job_view_dialog.cc
src/wx/job_view_dialog.h

index 28316e12e07c93d49f9f5e36ff7cf22aa85783a3..b00037241a20006504efc8b03a94d9bcb1238684 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-02-06  Carl Hetherington  <cth@carlh.net>
+
+       * Fix display of progress meter (and crash) when sending emails
+       from the KDM creator (#1045).
+
 2017-01-28  Carl Hetherington  <cth@carlh.net>
 
        * Add priority control buttons to batch converter (#961).
index 13c3bc7ab691d2896e3bf4b6982ae02f75e04d27..4aa2e3c2bdd98b305b8eced6889ee72a5b85c57b 100644 (file)
@@ -33,6 +33,7 @@ JobView::JobView (shared_ptr<Job> job, wxWindow* parent, wxWindow* container, wx
        , _table (table)
        , _parent (parent)
        , _container (container)
+       , _gauge (0)
 {
 
 }
@@ -78,7 +79,7 @@ JobView::setup ()
 void
 JobView::maybe_pulse ()
 {
-       if (_job->running() && !_job->progress ()) {
+       if (_gauge && _job->running() && !_job->progress()) {
                _gauge->Pulse ();
        }
 }
index c1c1c0c55d01f4f77bb5ef84b8356ef287e39bca..a49818cc8c5d420fc48a4d72dfe13478451270a0 100644 (file)
 
 #include "job_view_dialog.h"
 #include "normal_job_view.h"
+#include "lib/job.h"
 
 using boost::shared_ptr;
 
 JobViewDialog::JobViewDialog (wxWindow* parent, wxString title, shared_ptr<Job> job)
        : TableDialog (parent, title, 4, 0, false)
+       , _job (job)
 {
        _view = new NormalJobView (job, this, this, _table);
+       _view->setup ();
        layout ();
        SetMinSize (wxSize (960, -1));
 
        Bind (wxEVT_TIMER, boost::bind (&JobViewDialog::periodic, this));
        _timer.reset (new wxTimer (this));
        _timer->Start (1000);
+
+       /* Start off with OK disabled and it will be enabled when the job is finished */
+       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+       if (ok) {
+               ok->Enable (false);
+       }
 }
 
 JobViewDialog::~JobViewDialog ()
@@ -44,4 +53,10 @@ void
 JobViewDialog::periodic ()
 {
        _view->maybe_pulse ();
+
+       shared_ptr<Job> job = _job.lock ();
+       wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
+       if (job && ok) {
+               ok->Enable (job->finished ());
+       }
 }
index ae22aba73512773b5647893fb010d438428720c5..54a6c1636d0c6951e9fcf4b03f1e75f6216b6ef0 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "table_dialog.h"
 #include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
 
 class JobView;
 class Job;
@@ -34,5 +35,6 @@ private:
        void periodic ();
 
        JobView* _view;
+       boost::weak_ptr<Job> _job;
        boost::shared_ptr<wxTimer> _timer;
 };