From aeb18e729d49009ac64f5c3831186294079690a3 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 30 Sep 2021 10:19:58 +0200 Subject: [PATCH] New preferences key "clear_undo_redo_stack_on_new_project", set to "1" by default: Clear Undo / Redo stack on new project or load project. Fixes Clear undo chain #2812 --- src/libslic3r/AppConfig.cpp | 3 +++ src/slic3r/GUI/Plater.cpp | 2 ++ src/slic3r/GUI/Preferences.cpp | 8 ++++++++ 3 files changed, 13 insertions(+) diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index f3a1d5988..26c5b470e 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -147,6 +147,9 @@ void AppConfig::set_defaults() if (get("order_volumes").empty()) set("order_volumes", "1"); + + if (get("clear_undo_redo_stack_on_new_project").empty()) + set("clear_undo_redo_stack_on_new_project", "1"); } else { #ifdef _WIN32 diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index f10bced9e..840fe59d0 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4695,6 +4695,8 @@ void Plater::priv::take_snapshot(const std::string& snapshot_name, const UndoRed model.wipe_tower.position = Vec2d(config.opt_float("wipe_tower_x"), config.opt_float("wipe_tower_y")); model.wipe_tower.rotation = config.opt_float("wipe_tower_rotation_angle"); } + if (snapshot_type == UndoRedo::SnapshotType::ProjectSeparator && wxGetApp().app_config->get("clear_undo_redo_stack_on_new_project") == "1") + this->undo_redo_stack().clear(); this->undo_redo_stack().take_snapshot(snapshot_name, model, view3D->get_canvas3d()->get_selection(), view3D->get_canvas3d()->get_gizmos_manager(), snapshot_data); if (snapshot_type == UndoRedo::SnapshotType::LeavingGizmoWithAction) // Filter all but the last UndoRedo::SnapshotType::GizmoAction in a row between the last UndoRedo::SnapshotType::EnteringGizmo and UndoRedo::SnapshotType::LeavingGizmoWithAction. diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 0687399b2..880723693 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -238,6 +238,14 @@ void PreferencesDialog::build(size_t selected_tab) option = Option(def, "show_splash_screen"); m_optgroup_general->append_single_option_line(option); + // Clear Undo / Redo stack on new project + def.label = L("Clear Undo / Redo stack on new project"); + def.type = coBool; + def.tooltip = L("Clear Undo / Redo stack on new project or when an existing project is loaded."); + def.set_default_value(new ConfigOptionBool{ app_config->get("clear_undo_redo_stack_on_new_project") == "1" }); + option = Option(def, "clear_undo_redo_stack_on_new_project"); + m_optgroup_general->append_single_option_line(option); + #if defined(_WIN32) || defined(__APPLE__) def.label = L("Enable support for legacy 3DConnexion devices"); def.type = coBool;