diff --git a/src/slic3r/GUI/ProgressStatusBar.cpp b/src/slic3r/GUI/ProgressStatusBar.cpp index 2f1937623..b48c5732b 100644 --- a/src/slic3r/GUI/ProgressStatusBar.cpp +++ b/src/slic3r/GUI/ProgressStatusBar.cpp @@ -67,16 +67,18 @@ ProgressStatusBar::ProgressStatusBar(wxWindow *parent, int id): } ProgressStatusBar::~ProgressStatusBar() { - if(m_timer->IsRunning()) m_timer->Stop(); + if(m_timer && m_timer->IsRunning()) m_timer->Stop(); } int ProgressStatusBar::get_progress() const { - return m_prog->GetValue(); + return m_prog ? m_prog->GetValue() : 0; } void ProgressStatusBar::set_progress(int val) { + if(!m_prog) return; + if(!m_prog->IsShown()) show_progress(true); if(val < 0) return; @@ -91,24 +93,28 @@ void ProgressStatusBar::set_progress(int val) int ProgressStatusBar::get_range() const { - return m_prog->GetRange(); + return m_prog ? m_prog->GetRange() : 0; } void ProgressStatusBar::set_range(int val) { - if(val != m_prog->GetRange()) { + if(m_prog && val != m_prog->GetRange()) { m_prog->SetRange(val); } } void ProgressStatusBar::show_progress(bool show) { - m_prog->Show(show); - m_prog->Pulse(); + if(m_prog) { + m_prog->Show(show); + m_prog->Pulse(); + } } void ProgressStatusBar::start_busy(int rate) { + if(!m_prog) return; + m_busy = true; show_progress(true); if (!m_timer->IsRunning()) { @@ -118,6 +124,8 @@ void ProgressStatusBar::start_busy(int rate) void ProgressStatusBar::stop_busy() { + if(!m_timer || !m_prog) return; + m_timer->Stop(); show_progress(false); m_prog->SetValue(0); @@ -126,13 +134,15 @@ void ProgressStatusBar::stop_busy() void ProgressStatusBar::set_cancel_callback(ProgressStatusBar::CancelFn ccb) { m_cancel_cb = ccb; - if(ccb) m_cancelbutton->Show(); - else m_cancelbutton->Hide(); + if(m_cancelbutton) { + if(ccb) m_cancelbutton->Show(); + else m_cancelbutton->Hide(); + } } void ProgressStatusBar::run(int rate) { - if(!m_timer->IsRunning()) { + if(m_timer && !m_timer->IsRunning()) { m_timer->Start(rate); } } @@ -140,12 +150,12 @@ void ProgressStatusBar::run(int rate) void ProgressStatusBar::embed(wxFrame *frame) { wxFrame* mf = frame ? frame : GUI::wxGetApp().mainframe; - mf->SetStatusBar(self); + if(mf) mf->SetStatusBar(self); } void ProgressStatusBar::set_status_text(const wxString& txt) { - self->SetStatusText(txt); + if(self) self->SetStatusText(txt); } void ProgressStatusBar::set_status_text(const std::string& txt) @@ -160,12 +170,12 @@ void ProgressStatusBar::set_status_text(const char *txt) void ProgressStatusBar::show_cancel_button() { - m_cancelbutton->Show(); + if(m_cancelbutton) m_cancelbutton->Show(); } void ProgressStatusBar::hide_cancel_button() { - m_cancelbutton->Hide(); + if(m_cancelbutton) m_cancelbutton->Hide(); } }