diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp index 514db73c02..1b81dc10a3 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.cpp @@ -1219,31 +1219,38 @@ bool GLGizmosManager::activate_gizmo(EType type) if (m_gizmos.empty() || m_current == type) return true; - GLGizmoBase* old_gizmo = m_current == Undefined ? nullptr : m_gizmos[m_current].get(); - GLGizmoBase* new_gizmo = type == Undefined ? nullptr : m_gizmos[type].get(); - - if (old_gizmo) { - old_gizmo->set_state(GLGizmoBase::Off); - if (old_gizmo->get_state() != GLGizmoBase::Off) + if (m_current != Undefined) { + // clean up previous gizmo + GLGizmoBase &old_gizmo = *m_gizmos[m_current]; + old_gizmo.set_state(GLGizmoBase::Off); + if (old_gizmo.get_state() != GLGizmoBase::Off) return false; // gizmo refused to be turned off, do nothing. - if (! m_parent.get_gizmos_manager().is_serializing() - && old_gizmo->wants_enter_leave_snapshots()) + if (!m_serializing + && old_gizmo.wants_enter_leave_snapshots()) Plater::TakeSnapshot snapshot(wxGetApp().plater(), - old_gizmo->get_gizmo_leaving_text(), + old_gizmo.get_gizmo_leaving_text(), UndoRedo::SnapshotType::LeavingGizmoWithAction); } - if (new_gizmo && ! m_parent.get_gizmos_manager().is_serializing() - && new_gizmo->wants_enter_leave_snapshots()) + // check deactivation of gizmo + if (type == Undefined) { + m_current = type; + return true; + } + + // set up new gizmo + GLGizmoBase& new_gizmo = *m_gizmos[type]; + if (!m_serializing && new_gizmo.wants_enter_leave_snapshots()) Plater::TakeSnapshot snapshot(wxGetApp().plater(), - new_gizmo->get_gizmo_entering_text(), + new_gizmo.get_gizmo_entering_text(), UndoRedo::SnapshotType::EnteringGizmo); m_current = type; + new_gizmo.set_state(GLGizmoBase::On); + if (new_gizmo.get_state() != GLGizmoBase::On) + return false; // gizmo refused to be turned on. - if (new_gizmo) - new_gizmo->set_state(GLGizmoBase::On); return true; } diff --git a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp index ed02574dfa..f0ad185b5e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmosManager.hpp @@ -174,7 +174,6 @@ public: void refresh_on_off_state(); void reset_all_states(); - bool is_serializing() const { return m_serializing; } bool open_gizmo(EType type); bool check_gizmos_closed_except(EType) const;