From 561737f407ea85c04cbd8f2cbbd0da04292cb509 Mon Sep 17 00:00:00 2001 From: Hanif Koh Date: Wed, 30 Sep 2026 12:45:26 +0800 Subject: [PATCH] Fix the CLI 3MF Export Crash After Rendering a Plate Thumbnail Since the CLI can open an OpenGL context (#15745) it renders plate thumbnails on export, and the viewport restore at the end of render_thumbnail_internal (#15674) then reads the plater through the wx application. The CLI has neither, so every --export-3mf on a machine with a display died with a segmentation fault after the first thumbnail. Skip the restore when there is no application or no plater; the GUI path is unchanged. --- src/slic3r/GUI/GLCanvas3D.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index ffa067308c..01ff6de714 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -6546,8 +6546,11 @@ void GLCanvas3D::render_thumbnail_internal(ThumbnailData& thumbnail_data, const // glsafe(::glClearColor(1.0f, 1.0f, 1.0f, 1.0f)); BOOST_LOG_TRIVIAL(info) << boost::format("render_thumbnail: finished"); - // Puts the canvas viewport back in place of the thumbnail one set above. - wxGetApp().plater()->get_camera().apply_viewport(); + // Puts the canvas viewport back in place of the thumbnail one set above. The CLI renders + // thumbnails with no application and no plater, so there is no canvas viewport to restore. + if (wxTheApp != nullptr) + if (Plater *plater = wxGetApp().plater(); plater != nullptr) + plater->get_camera().apply_viewport(); } void GLCanvas3D::render_thumbnail_framebuffer(ThumbnailData& thumbnail_data, unsigned int w, unsigned int h, const ThumbnailsParams& thumbnail_params,