From f9e46ea8715c891d211f3cfdc2f204d5f026bd07 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Fri, 2 Sep 2022 19:35:24 +0200 Subject: [PATCH] Follow-up https://github.com/Prusa-Development/PrusaSlicerPrivate/commit/31e4a20f6dbded186e3a0d0c5b8fba9cb79029e6 : some code refactoring --- src/slic3r/GUI/Tab.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 05aa7e2ea..8c6b349b4 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -603,16 +603,10 @@ void Tab::update_changed_ui() if (m_type == Preset::TYPE_PRINTER) { { auto check_bed_custom_options = [](std::vector& keys) { - bool was_deleted = false; - for (std::vector::iterator it = keys.begin(); it != keys.end(); ) { - if (*it == "bed_custom_texture" || *it == "bed_custom_model") { - it = keys.erase(it); - was_deleted = true; - } - else - ++it; - } - if (was_deleted && std::find(keys.begin(), keys.end(), "bed_shape") == keys.end()) + size_t old_keys_size = keys.size(); + keys.erase(std::remove_if(keys.begin(), keys.end(), [](const std::string& key) { + return key == "bed_custom_texture" || key == "bed_custom_model"; }), keys.end()); + if (old_keys_size != keys.size() && std::find(keys.begin(), keys.end(), "bed_shape") == keys.end()) keys.emplace_back("bed_shape"); }; check_bed_custom_options(dirty_options);