mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-14 00:52:04 +00:00
💥Fix crash when return from assembly mode linux (#13091)
* Fix return from assembly linux * Tie deferred callback to canvas lifetime and add shutdown guards Use m_canvas->CallAfter instead of wxGetApp().CallAfter to ensure the callback is only executed if the canvas is still alive. Add early returns if wxGetApp().is_closing() is true before accessing plater or the 3D canvas, reducing the risk of use-after-free during application shutdown. Addresses feedback regarding potential UI teardown race conditions. * copilot suggestion * Use local reference to wxGetApp() in Return button callback Replace multiple calls to wxGetApp() with a single local reference to improve readability and avoid redundant function calls.
This commit is contained in:
@@ -8480,11 +8480,27 @@ void GLCanvas3D::_render_return_toolbar() const
|
||||
ImVec2 margin = ImVec2(10.0f, 5.0f);
|
||||
|
||||
if (ImGui::ImageTextButton(real_size,_utf8(L("Return")).c_str(), m_return_toolbar.get_return_texture_id(), button_icon_size, uv0, uv1, -1, bg_col, tint_col, margin)) {
|
||||
if (m_canvas != nullptr)
|
||||
wxPostEvent(m_canvas, SimpleEvent(EVT_GLVIEWTOOLBAR_3D));
|
||||
const_cast<GLGizmosManager*>(&m_gizmos)->reset_all_states();
|
||||
wxGetApp().plater()->get_view3D_canvas3D()->get_gizmos_manager().reset_all_states();
|
||||
wxGetApp().plater()->get_view3D_canvas3D()->reload_scene(true);
|
||||
if (m_canvas != nullptr && !wxGetApp().is_closing()) {
|
||||
m_canvas->CallAfter([]() {
|
||||
auto& app = wxGetApp();
|
||||
if (app.is_closing())
|
||||
return;
|
||||
|
||||
auto* plater = app.plater();
|
||||
if (plater == nullptr)
|
||||
return;
|
||||
|
||||
plater->select_view_3D("3D");
|
||||
|
||||
auto* view3d_canvas = plater->get_view3D_canvas3D();
|
||||
if (view3d_canvas == nullptr)
|
||||
return;
|
||||
|
||||
view3d_canvas->get_gizmos_manager().reset_all_states();
|
||||
view3d_canvas->reload_scene(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
ImGui::PopStyleColor(5);
|
||||
ImGui::PopStyleVar(1);
|
||||
|
||||
Reference in New Issue
Block a user