From fe07bde3852f699176570cefc73dfd12b6815020 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Fri, 6 Sep 2019 13:49:15 +0200 Subject: [PATCH] Do not render intermediate states while reload from disk action is taking place --- src/slic3r/GUI/GLCanvas3D.cpp | 3 ++- src/slic3r/GUI/GLCanvas3D.hpp | 4 ++++ src/slic3r/GUI/Plater.cpp | 6 ++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0494af3d5..a6abc83fd 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1127,6 +1127,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar , m_retina_helper(nullptr) #endif , m_in_render(false) + , m_render_enabled(true) , m_bed(bed) , m_camera(camera) , m_view_toolbar(view_toolbar) @@ -1513,7 +1514,7 @@ void GLCanvas3D::update_volumes_colors_by_extruder() void GLCanvas3D::render() { - if (m_in_render) + if (!m_render_enabled || m_in_render) { // if called recursively, return m_dirty = true; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 879584528..d805cd60f 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -403,6 +403,7 @@ private: std::unique_ptr m_retina_helper; #endif bool m_in_render; + bool m_render_enabled; LegendTexture m_legend_texture; WarningTexture m_warning_texture; wxTimer m_timer; @@ -533,6 +534,9 @@ public: void enable_dynamic_background(bool enable); void allow_multisample(bool allow); + void enable_render(bool enable) { m_render_enabled = enable; } + bool is_render_enabled() const { return m_render_enabled; } + void zoom_to_bed(); void zoom_to_volumes(); void zoom_to_selection(); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4442c65e4..6e2d3b1b5 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3087,6 +3087,9 @@ void Plater::priv::reload_from_disk() auto *object_orig = model.objects[obj_orig_idx]; std::vector input_paths(1, object_orig->input_file); + // disable render to avoid to show intermediate states + view3D->get_canvas3d()->enable_render(false); + const auto new_idxs = load_files(input_paths, true, false); for (const auto idx : new_idxs) { @@ -3108,6 +3111,9 @@ void Plater::priv::reload_from_disk() remove(obj_orig_idx); + // re-enable render + view3D->get_canvas3d()->enable_render(true); + // the previous call to remove() clears the selection // select newly added objects selection.clear();