diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index 3eb174694..744275e22 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -2293,9 +2293,9 @@ void _3DScene::load_preview(wxGLCanvas* canvas, const std::vector& s_canvas_mgr.load_preview(canvas, str_tool_colors); } -void _3DScene::reset_legend_texture() +void _3DScene::reset_legend_texture(wxGLCanvas* canvas) { - s_canvas_mgr.reset_legend_texture(); + s_canvas_mgr.reset_legend_texture(canvas); } } // namespace Slic3r diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 484d6028d..a5f4c5189 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -602,7 +602,7 @@ public: static void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors); static void load_preview(wxGLCanvas* canvas, const std::vector& str_tool_colors); - static void reset_legend_texture(); + static void reset_legend_texture(wxGLCanvas* canvas); static void thick_lines_to_verts(const Lines& lines, const std::vector& widths, const std::vector& heights, bool closed, double top_z, GLVolume& volume); static void thick_lines_to_verts(const Lines3& lines, const std::vector& widths, const std::vector& heights, bool closed, GLVolume& volume); diff --git a/src/slic3r/GUI/GLCanvas3DManager.cpp b/src/slic3r/GUI/GLCanvas3DManager.cpp index 09821f853..771aa159e 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.cpp +++ b/src/slic3r/GUI/GLCanvas3DManager.cpp @@ -580,13 +580,11 @@ void GLCanvas3DManager::load_preview(wxGLCanvas* canvas, const std::vectorsecond->load_preview(str_tool_colors); } -void GLCanvas3DManager::reset_legend_texture() +void GLCanvas3DManager::reset_legend_texture(wxGLCanvas* canvas) { - for (CanvasesMap::value_type& canvas : m_canvases) - { - if (canvas.second != nullptr) - canvas.second->reset_legend_texture(); - } + CanvasesMap::iterator it = _get_canvas(canvas); + if (it != m_canvases.end()) + it->second->reset_legend_texture(); } void GLCanvas3DManager::register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback) diff --git a/src/slic3r/GUI/GLCanvas3DManager.hpp b/src/slic3r/GUI/GLCanvas3DManager.hpp index 452584550..d3b7b177c 100644 --- a/src/slic3r/GUI/GLCanvas3DManager.hpp +++ b/src/slic3r/GUI/GLCanvas3DManager.hpp @@ -154,7 +154,7 @@ public: void load_gcode_preview(wxGLCanvas* canvas, const GCodePreviewData* preview_data, const std::vector& str_tool_colors); void load_preview(wxGLCanvas* canvas, const std::vector& str_tool_colors); - void reset_legend_texture(); + void reset_legend_texture(wxGLCanvas* canvas); void register_on_viewport_changed_callback(wxGLCanvas* canvas, void* callback); void register_on_double_click_callback(wxGLCanvas* canvas, void* callback); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index c70a6080c..fc3d362e9 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -214,7 +214,8 @@ void Preview::set_number_extruders(unsigned int number_extruders) void Preview::reset_gcode_preview_data() { m_gcode_preview_data->reset(); - _3DScene::reset_legend_texture(); + if (m_canvas != nullptr) + _3DScene::reset_legend_texture(m_canvas); } void Preview::set_canvas_as_dirty() @@ -290,10 +291,11 @@ void Preview::load_print() if (n_layers == 0) { reset_sliders(); - _3DScene::reset_legend_texture(); - if (m_canvas) + if (m_canvas != nullptr) + { + _3DScene::reset_legend_texture(m_canvas); m_canvas->Refresh(); - + } return; }