fix exit soft and maybe crash on canvas 3d panel.

This commit is contained in:
alves
2026-02-05 15:35:29 +08:00
parent 32a3b401cb
commit 64e08febbe
2 changed files with 29 additions and 13 deletions

View File

@@ -1331,10 +1331,16 @@ void GLCanvas3D::reset_volumes()
m_dirty = true; m_dirty = true;
auto pLater = wxGetApp().plater(); auto pLater = wxGetApp().plater();
if (pLater) {
if (pLater && wxGetApp().plater()->get_notification_manager()) auto* notification_mgr = pLater->get_notification_manager();
{ if (notification_mgr) {
_set_warning_notification(EWarning::ObjectOutside, false); // Only update notification if we can safely access Plater's current canvas
// This ensures Plater::priv structure is still valid
auto* canvas = pLater->get_current_canvas3D();
if (canvas) {
_set_warning_notification(EWarning::ObjectOutside, false);
}
}
} }
} }

View File

@@ -8839,16 +8839,26 @@ void Plater::priv::set_current_canvas_as_dirty()
GLCanvas3D* Plater::priv::get_current_canvas3D(bool exclude_preview) GLCanvas3D* Plater::priv::get_current_canvas3D(bool exclude_preview)
{ {
if (current_panel == view3D) // During destruction, these pointers may be null or point to destroyed objects
return view3D->get_canvas3d(); // Add null checks to prevent crashes during shutdown
else if (!exclude_preview && (current_panel == preview)) if (current_panel == view3D) {
return preview->get_canvas3d(); if (view3D)
else if (current_panel == assemble_view) return view3D->get_canvas3d();
return assemble_view->get_canvas3d(); }
else //BBS default set to view3D else if (!exclude_preview && (current_panel == preview)) {
if (preview)
return preview->get_canvas3d();
}
else if (current_panel == assemble_view) {
if (assemble_view)
return assemble_view->get_canvas3d();
}
//BBS default set to view3D, but check if it's still valid
if (view3D)
return view3D->get_canvas3d(); return view3D->get_canvas3d();
//return (current_panel == view3D) ? view3D->get_canvas3d() : ((current_panel == preview) ? preview->get_canvas3d() : nullptr); return nullptr;
} }
void Plater::priv::unbind_canvas_event_handlers() void Plater::priv::unbind_canvas_event_handlers()