diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index ccbe0ab54..6c6f9584f 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -48,6 +48,7 @@ #ifdef SLIC3R_GUI #include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI_App.hpp" + #include "slic3r/GUI/3DScene.hpp" #endif /* SLIC3R_GUI */ using namespace Slic3r; @@ -505,7 +506,10 @@ int CLI::run(int argc, char **argv) if (! m_extra_config.empty()) gui->mainframe->load_config(m_extra_config); }); - return wxEntry(argc, argv); + int result = wxEntry(argc, argv); + //FIXME this is a workaround for the PrusaSlicer 2.1 release. + _3DScene::destroy(); + return result; #else /* SLIC3R_GUI */ // No GUI support. Just print out a help. this->print_help(false); diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 8d1a154b4..d764d6cef 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -2007,6 +2007,11 @@ bool _3DScene::init(wxGLCanvas* canvas) return s_canvas_mgr.init(canvas); } +void _3DScene::destroy() +{ + s_canvas_mgr.destroy(); +} + GUI::GLCanvas3D* _3DScene::get_canvas(wxGLCanvas* canvas) { return s_canvas_mgr.get_canvas(canvas); diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index e0603ebc0..5acc85217 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -647,6 +647,7 @@ public: static void remove_all_canvases(); static bool init(wxGLCanvas* canvas); + static void destroy(); static GUI::GLCanvas3D* get_canvas(wxGLCanvas* canvas); diff --git a/src/slic3r/GUI/GLCanvas3DManager.cpp b/src/slic3r/GUI/GLCanvas3DManager.cpp index c096c0e9f..a764fec66 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -197,11 +197,7 @@ GLCanvas3DManager::GLCanvas3DManager() GLCanvas3DManager::~GLCanvas3DManager() { - if (m_context != nullptr) - { - delete m_context; - m_context = nullptr; - } + this->destroy(); } bool GLCanvas3DManager::add(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar& view_toolbar) @@ -282,6 +278,15 @@ bool GLCanvas3DManager::init(wxGLCanvas* canvas) return false; } +void GLCanvas3DManager::destroy() +{ + if (m_context != nullptr) + { + delete m_context; + m_context = nullptr; + } +} + GLCanvas3D* GLCanvas3DManager::get_canvas(wxGLCanvas* canvas) { CanvasesMap::const_iterator it = do_get_canvas(canvas); diff --git a/src/slic3r/GUI/GLCanvas3DManager.hpp b/src/slic3r/GUI/GLCanvas3DManager.hpp index c0e0df622..760266a27 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -91,6 +91,7 @@ public: void init_gl(); bool init(wxGLCanvas* canvas); + void destroy(); GLCanvas3D* get_canvas(wxGLCanvas* canvas);