From 19d2115f207d1319b22cc15b8d50234b0a4d4a56 Mon Sep 17 00:00:00 2001 From: supermerill Date: Sat, 28 Nov 2020 20:50:24 +0100 Subject: [PATCH] allow bad key/value from imported .3mf/gcode these will be silently ignored and so the default value will be used. --- src/libslic3r/Config.cpp | 17 ++++++++--------- src/libslic3r/PrintConfig.cpp | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/Config.cpp b/src/libslic3r/Config.cpp index 3a99d151b..e9d654bbf 100644 --- a/src/libslic3r/Config.cpp +++ b/src/libslic3r/Config.cpp @@ -530,10 +530,11 @@ bool ConfigBase::set_deserialize_nothrow(const t_config_option_key &opt_key_src, return this->set_deserialize_raw(opt_key, value, append); } -void ConfigBase::set_deserialize(const t_config_option_key &opt_key_src, const std::string &value_src, bool append) +void ConfigBase::set_deserialize(const t_config_option_key& opt_key_src, const std::string& value_src, bool append) { - if (! this->set_deserialize_nothrow(opt_key_src, value_src, append)) - throw BadOptionTypeException(format("ConfigBase::set_deserialize() failed for parameter \"%1%\", value \"%2%\"", opt_key_src, value_src)); + if (!this->set_deserialize_nothrow(opt_key_src, value_src, append)) { + throw BadOptionTypeException(format("ConfigBase::set_deserialize() failed for parameter \"%1%\", value \"%2%\"", opt_key_src, value_src)); + } } void ConfigBase::set_deserialize(std::initializer_list items) @@ -580,10 +581,7 @@ bool ConfigBase::set_deserialize_raw(const t_config_option_key &opt_key_src, con if (opt == nullptr) throw new UnknownOptionException(opt_key); bool ok= opt->deserialize(value, append); - if (!ok) { - return opt->deserialize(value, append); - } - return true; + return ok; } // Return an absolute value of a possibly relative config variable. @@ -783,8 +781,9 @@ size_t ConfigBase::load_from_gcode_string(const char* str) if (key == nullptr) break; try { - this->set_deserialize(std::string(key, key_end), std::string(value, end)); - ++num_key_value_pairs; + //change it from set_deserialize to set_deserialize_nothrow to allow bad/old config to swtch to default value. + if(this->set_deserialize_nothrow(std::string(key, key_end), std::string(value, end))) + ++num_key_value_pairs; } catch (UnknownOptionException & /* e */) { // ignore diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 99ad002c4..662b7b0b9 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -714,7 +714,6 @@ void PrintConfigDef::init_fff_params() def->tooltip = L("Fill pattern for bottom infill. This only affects the bottom visible layer, and not its adjacent solid shells."); def->cli = "bottom-fill-pattern|external-fill-pattern=s"; def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); - def->enum_values.push_back("rectilinear"); def->enum_values.push_back("rectilineargapfill"); def->enum_values.push_back("monotonic");