Fixed a crash caused by double-free on application close event (Linux)

This commit is contained in:
Lukas Matena 2019-01-28 12:12:14 +01:00
parent 61d59a7a2e
commit ddcb2b1c23
3 changed files with 8 additions and 26 deletions

View File

@ -270,16 +270,11 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) {
void GUI_App::recreate_GUI() void GUI_App::recreate_GUI()
{ {
std::cerr << "recreate_GUI" << std::endl; // to make sure nobody accesses data from the soon-to-be-destroyed widgets:
tabs_list.clear();
plater_ = nullptr;
clear_tabs_list(); MainFrame* topwindow = mainframe;
if (plater_) {
// before creating a new plater let's delete old one
plater_->Destroy();
plater_ = nullptr;
}
MainFrame* topwindow = dynamic_cast<MainFrame*>(GetTopWindow());
mainframe = new MainFrame(); mainframe = new MainFrame();
sidebar().obj_list()->init_objects(); // propagate model objects to object list sidebar().obj_list()->init_objects(); // propagate model objects to object list
@ -691,15 +686,6 @@ void GUI_App::load_current_presets()
} }
} }
void GUI_App::clear_tabs_list()
{
for (auto tab : tabs_list) {
tab->Destroy();
tab = nullptr;
}
tabs_list.clear();
}
#ifdef __APPLE__ #ifdef __APPLE__
// wxWidgets override to get an event on open files. // wxWidgets override to get an event on open files.
void GUI_App::MacOpenFiles(const wxArrayString &fileNames) void GUI_App::MacOpenFiles(const wxArrayString &fileNames)

View File

@ -134,7 +134,6 @@ public:
bool check_unsaved_changes(); bool check_unsaved_changes();
bool checked_tab(Tab* tab); bool checked_tab(Tab* tab);
void load_current_presets(); void load_current_presets();
void clear_tabs_list();
#ifdef __APPLE__ #ifdef __APPLE__
// wxWidgets override to get an event on open files. // wxWidgets override to get an event on open files.

View File

@ -95,14 +95,10 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
_3DScene::remove_all_canvases(); _3DScene::remove_all_canvases();
// Slic3r::GUI::deregister_on_request_update_callback(); // Slic3r::GUI::deregister_on_request_update_callback();
// destroy and set to null tabs and a platter // set to null tabs and a platter
// to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing // to avoid any manipulations with them from App->wxEVT_IDLE after of the mainframe closing
wxGetApp().clear_tabs_list(); wxGetApp().tabs_list.clear();
if (wxGetApp().plater_) { wxGetApp().plater_ = nullptr;
// before creating a new plater let's delete old one
wxGetApp().plater_->Destroy();
wxGetApp().plater_ = nullptr;
}
// propagate event // propagate event
event.Skip(); event.Skip();
@ -113,6 +109,7 @@ wxFrame(NULL, wxID_ANY, SLIC3R_BUILD, wxDefaultPosition, wxDefaultSize, wxDEFAUL
update_ui_from_settings(); // FIXME (?) update_ui_from_settings(); // FIXME (?)
} }
void MainFrame::init_tabpanel() void MainFrame::init_tabpanel()
{ {
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL); m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL);