From 2c9bd86a706fdc46d5ae295a1e03d0aa47cbfc69 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 11 Mar 2020 12:19:52 +0100 Subject: [PATCH] Fix of crash and/or assert when changing language --- src/slic3r/GUI/GLCanvas3D.cpp | 6 +++--- src/slic3r/GUI/GUI_App.cpp | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index fc8a800d1..b01e46221 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -3191,6 +3191,9 @@ std::string format_mouse_event_debug_message(const wxMouseEvent &evt) void GLCanvas3D::on_mouse(wxMouseEvent& evt) { + if (!m_initialized || !_set_current()) + return; + #if ENABLE_RETINA_GL const float scale = m_retina_helper->get_scale_factor(); evt.SetX(evt.GetX() * scale); @@ -3260,9 +3263,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) return; } - if (m_picking_enabled) - _set_current(); - int selected_object_idx = m_selection.get_object_idx(); int layer_editing_object_idx = is_layers_editing_enabled() ? selected_object_idx : -1; m_layers_editing.select_object(*m_model, layer_editing_object_idx); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 47b49748d..48ee9e32c 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -860,14 +860,19 @@ void GUI_App::add_config_menu(wxMenuBar *menu) /* Before change application language, let's check unsaved changes on 3D-Scene * and draw user's attention to the application restarting after a language change */ - wxMessageDialog dialog(nullptr, - _(L("Switching the language will trigger application restart.\n" - "You will lose content of the plater.")) + "\n\n" + - _(L("Do you want to proceed?")), - wxString(SLIC3R_APP_NAME) + " - " + _(L("Language selection")), - wxICON_QUESTION | wxOK | wxCANCEL); - if ( dialog.ShowModal() == wxID_CANCEL) - return; + { + // the dialog needs to be destroyed before the call to switch_language() + // or sometimes the application crashes into wxDialogBase() destructor + // so we put it into an inner scope + wxMessageDialog dialog(nullptr, + _(L("Switching the language will trigger application restart.\n" + "You will lose content of the plater.")) + "\n\n" + + _(L("Do you want to proceed?")), + wxString(SLIC3R_APP_NAME) + " - " + _(L("Language selection")), + wxICON_QUESTION | wxOK | wxCANCEL); + if (dialog.ShowModal() == wxID_CANCEL) + return; + } switch_language(); break;