set_progress (1);
set_state (FINISHED_ERROR);
- set_error (String::compose ("%1 (%2)", e.what(), boost::filesystem::path (e.filename()).leaf()));
+ string m = String::compose ("An error occurred whilst handling the file %1.", boost::filesystem::path (e.filename()).leaf());
+
+ boost::filesystem::space_info const s = boost::filesystem::space (e.filename());
+ if (s.available < pow (1024, 3)) {
+ m += "\n\nThe drive that the film is stored on is low in disc space. Free some more space and try again.";
+ }
+
+ set_error (e.what(), m);
+
} catch (std::exception& e) {
set_progress (1);
set_state (FINISHED_ERROR);
- set_error (e.what ());
+ set_error (
+ e.what (),
+ "It is not known what caused this error. The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)"
+ );
} catch (...) {
set_progress (1);
set_state (FINISHED_ERROR);
- set_error ("unknown exception");
+ set_error (
+ "Unknown error",
+ "It is not known what caused this error. The best idea is to report the problem to the DVD-o-matic mailing list (dvdomatic@carlh.net)"
+ );
}
}
_stack.push_back (Level (a));
}
-/** @return Any error string that the job has generated */
string
-Job::error () const
+Job::error_details () const
+{
+ boost::mutex::scoped_lock lm (_state_mutex);
+ return _error_details;
+}
+
+/** @return A summary of any error that the job has generated */
+string
+Job::error_summary () const
{
boost::mutex::scoped_lock lm (_state_mutex);
- return _error;
+ return _error_summary;
}
/** Set the current error string.
* @param e New error string.
*/
void
-Job::set_error (string e)
+Job::set_error (string s, string d)
{
boost::mutex::scoped_lock lm (_state_mutex);
- _error = e;
+ _error_summary = s;
+ _error_details = d;
}
/** Say that this job's progress will be unknown until further notice */
} else if (finished_ok ()) {
s << "OK (ran for " << seconds_to_hms (_ran_for) << ")";
} else if (finished_in_error ()) {
- s << "Error (" << error() << ")";
+ s << "Error (" << error_summary() << ")";
}
return s.str ();
bool finished_ok () const;
bool finished_in_error () const;
- std::string error () const;
+ std::string error_summary () const;
+ std::string error_details () const;
int elapsed_time () const;
virtual std::string status () const;
};
void set_state (State);
- void set_error (std::string e);
+ void set_error (std::string s, std::string d);
/** Film for this job */
boost::shared_ptr<Film> _film;
mutable boost::mutex _state_mutex;
/** current state of the job */
State _state;
- /** message for an error that has occurred (when state == FINISHED_ERROR) */
- std::string _error;
+ /** summary of an error that has occurred (when state == FINISHED_ERROR) */
+ std::string _error_summary;
+ std::string _error_details;
/** time that this job was started */
time_t _start_time;
film_viewer = new FilmViewer (film, panel);
JobManagerView* job_manager_view = new JobManagerView (panel);
- wxSizer* rhs_sizer = new wxBoxSizer (wxVERTICAL);
- rhs_sizer->Add (film_viewer, 3, wxEXPAND | wxALL);
- rhs_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL);
+ wxSizer* top_sizer = new wxBoxSizer (wxHORIZONTAL);
+ top_sizer->Add (film_editor, 0, wxALL, 6);
+ top_sizer->Add (film_viewer, 1, wxEXPAND | wxALL, 6);
- wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
- main_sizer->Add (film_editor, 0, wxALL, 6);
- main_sizer->Add (rhs_sizer, 1, wxEXPAND | wxALL, 6);
+ wxBoxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
+ main_sizer->Add (top_sizer, 2, wxEXPAND | wxALL, 6);
+ main_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
panel->SetSizer (main_sizer);
set_menu_sensitivity ();
h_sizer->Add (_play_button, 0, wxEXPAND);
h_sizer->Add (_slider, 1, wxEXPAND);
- _v_sizer->Add (h_sizer, 0, wxEXPAND);
+ _v_sizer->Add (h_sizer, 0, wxEXPAND | wxALL, 6);
_panel->Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (FilmViewer::paint_panel), 0, this);
_panel->Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (FilmViewer::panel_sized), 0, this);
using std::string;
using std::list;
+using std::map;
using boost::shared_ptr;
/** Must be called in the GUI thread */
sizer->Add (_panel, 1, wxEXPAND);
SetSizer (sizer);
- _table = new wxFlexGridSizer (3, 6, 6);
+ _table = new wxFlexGridSizer (4, 6, 6);
_table->AddGrowableCol (1, 1);
_panel->SetSizer (_table);
r.message = new wxStaticText (_panel, wxID_ANY, std_to_wx (""));
_table->Insert (index + 2, r.message, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
+
+ r.details = new wxButton (_panel, wxID_ANY, _("Details..."));
+ r.details->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (JobManagerView::details_clicked), 0, this);
+ r.details->Enable (false);
+ _table->Insert (index + 3, r.details, 1, wxALIGN_CENTER_VERTICAL | wxALL, 6);
_job_records[*i] = r;
}
_job_records[*i].gauge->SetValue (100);
_job_records[*i].message->SetLabel (std_to_wx (st));
_job_records[*i].finalised = true;
+ if (!(*i)->error_details().empty ()) {
+ _job_records[*i].details->Enable (true);
+ }
}
index += 3;
_table->Layout ();
FitInside ();
}
+
+void
+JobManagerView::details_clicked (wxCommandEvent& ev)
+{
+ wxObject* o = ev.GetEventObject ();
+
+ for (map<boost::shared_ptr<Job>, JobRecord>::iterator i = _job_records.begin(); i != _job_records.end(); ++i) {
+ if (i->second.details == o) {
+ string s = i->first->error_summary();
+ s[0] = toupper (s[0]);
+ error_dialog (this, String::compose ("%1.\n\n%2", s, i->first->error_details()));
+ }
+ }
+}
private:
void periodic (wxTimerEvent &);
+ void details_clicked (wxCommandEvent &);
boost::shared_ptr<wxTimer> _timer;
wxPanel* _panel;
struct JobRecord {
wxGauge* gauge;
wxStaticText* message;
+ wxButton* details;
bool finalised;
};