forked from viewit/OrcaSlicer-KX
Plater is a wxWindow subclass holding a pImpl (unique_ptr<priv> p). On app
exit the member p is destroyed before the wxWindow base destructor runs
DestroyChildren(), so the child View3D/GLCanvas3D windows are torn down
*after* p has already been freed.
GLCanvas3D::~GLCanvas3D() -> reset_volumes() then reaches back into the dead
Plater via two callbacks, each dereferencing the freed p:
- Selection::clear() -> plater()->canvas3D() -> p->get_current_canvas3D()
- _set_warning_notification() -> plater()->get_notification_manager()
-> p->notification_manager
Which one fires depends on scene state (selection vs. volumes present), so
quitting with a model loaded reliably crashes with EXC_BAD_ACCESS.
Guard both callbacks with the existing wxGetApp().is_closing() flag (set in
MainFrame's close handler and GUI_App::shutdown(), both before
DoDelayedCleanup destroys the frame). Both calls are UI-only side effects
that are no-ops during shutdown, so normal-use behavior is unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>