Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortamasmeszaros <meszaros.q@gmail.com>2019-05-13 11:20:37 +0300
committertamasmeszaros <meszaros.q@gmail.com>2019-05-13 11:20:37 +0300
commit52d042a1c9dea82d10f5e658faf7187f195754de (patch)
tree774d88e1238e246e2090be08b3dd7bcaed5c4901 /src/slic3r/GUI/ProgressStatusBar.cpp
parent80d8adc70ad3fdb412b77d519fb6af03111ae428 (diff)
Prevent segfaults from callbacks when statusbar elements are deallocated
happens on application exit when a job (arrange or optimize orientation) is running.
Diffstat (limited to 'src/slic3r/GUI/ProgressStatusBar.cpp')
-rw-r--r--src/slic3r/GUI/ProgressStatusBar.cpp36
1 files changed, 23 insertions, 13 deletions
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();
}
}