Fixed crash after change of a language

+ Updating of a mode after recreation
This commit is contained in:
YuSanka 2019-03-26 10:08:57 +01:00
parent d0171b5687
commit 910979cf73

View file

@ -14,6 +14,7 @@
#include <wx/menu.h> #include <wx/menu.h>
#include <wx/menuitem.h> #include <wx/menuitem.h>
#include <wx/filedlg.h> #include <wx/filedlg.h>
#include <wx/progdlg.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
#include <wx/filefn.h> #include <wx/filefn.h>
@ -279,31 +280,50 @@ void GUI_App::set_label_clr_sys(const wxColour& clr) {
void GUI_App::recreate_GUI() void GUI_App::recreate_GUI()
{ {
// Weird things happen as the Paint messages are floating around the windows being destructed.
// Avoid the Paint messages by hiding the main window.
// Also the application closes much faster without these unnecessary screen refreshes.
// In addition, there were some crashes due to the Paint events sent to already destructed windows.
mainframe->Show(false);
const auto msg_name = _(L("Changing of an application language")) + dots;
wxProgressDialog dlg(msg_name, msg_name);
dlg.Pulse();
// to make sure nobody accesses data from the soon-to-be-destroyed widgets: // to make sure nobody accesses data from the soon-to-be-destroyed widgets:
tabs_list.clear(); tabs_list.clear();
plater_ = nullptr; plater_ = nullptr;
dlg.Update(10, _(L("Recreating")) + dots);
MainFrame* topwindow = mainframe; MainFrame* topwindow = mainframe;
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
if (topwindow) { if (topwindow) {
SetTopWindow(mainframe); SetTopWindow(mainframe);
dlg.Update(30, _(L("Recreating")) + dots);
topwindow->Destroy(); topwindow->Destroy();
} }
dlg.Update(80, _(L("Loading of a current presets")) + dots);
m_printhost_job_queue.reset(new PrintHostJobQueue(mainframe->printhost_queue_dlg())); m_printhost_job_queue.reset(new PrintHostJobQueue(mainframe->printhost_queue_dlg()));
load_current_presets(); load_current_presets();
mainframe->Show(true); mainframe->Show(true);
// On OSX the UI was not initialized correctly if the wizard was called dlg.Update(90, _(L("Loading of a mode view")) + dots);
// before the UI was up and running.
CallAfter([]() { update_mode();
// Run the config wizard, don't offer the "reset user profile" checkbox.
config_wizard_startup(true); // #ys_FIXME_delete_after_testing Do we still need this ?
}); // CallAfter([]() {
// // Run the config wizard, don't offer the "reset user profile" checkbox.
// config_wizard_startup(true);
// });
} }
void GUI_App::system_info() void GUI_App::system_info()