From 40121c56e9a61ab053930f09a34ac6cd1df2bda6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Fri, 9 Oct 2020 16:07:34 +0200 Subject: [PATCH] Fixed an undo/redo problem with SLA gizmo When the undo/redo stack opened the SLA gizmo, it would erroneously obliterate all future snapshots --- src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp index c9db14968e..e626aa7f86 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSlaSupports.cpp @@ -889,16 +889,18 @@ void GLGizmoSlaSupports::on_set_state() return; if (m_state == On && m_old_state != On) { // the gizmo was just turned on - // This function can be called from undo/redo, when selection (and hence - // common gizmos data are not yet deserialized. The CallAfter should put - // this off until after the update is done. - wxGetApp().CallAfter([this]() { - Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on"))); + if (! m_parent.get_gizmos_manager().is_serializing()) { + // Only take the snapshot when the USER opens the gizmo. Common gizmos + // data are not yet available, the CallAfter will postpone taking the + // snapshot until they are. No, it does not feel right. + wxGetApp().CallAfter([this]() { + Plater::TakeSnapshot snapshot(wxGetApp().plater(), _(L("SLA gizmo turned on"))); + }); + } - // Set default head diameter from config. - const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; - m_new_point_head_diameter = static_cast(cfg.option("support_head_front_diameter"))->value; - }); + // Set default head diameter from config. + const DynamicPrintConfig& cfg = wxGetApp().preset_bundle->sla_prints.get_edited_preset().config; + m_new_point_head_diameter = static_cast(cfg.option("support_head_front_diameter"))->value; } if (m_state == Off && m_old_state != Off) { // the gizmo was just turned Off bool will_ask = m_editing_mode && unsaved_changes();