FIX: invalid params in user preset load

jira: NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I7e9cdabb2d9c285db841c810f32aee5943b4db82
(cherry picked from commit ff8d764e7256cec1e7cd1d4d3d034590eb846f45)
(cherry picked from commit fb0461f3459afcfc80165442277ba8c54e232a39)
This commit is contained in:
xun.zhang
2025-06-04 18:13:58 +08:00
committed by Noisyfox
parent 8c64808ae5
commit 3c051f4180
5 changed files with 97 additions and 21 deletions

View File

@@ -81,7 +81,16 @@ PresetBundle::PresetBundle()
this->filaments.default_preset().compatible_printers_condition();
this->filaments.default_preset().inherits();
// Set all the nullable values to nils.
this->filaments.default_preset().config.null_nullables();
{
auto& default_config = this->filaments.default_preset().config;
for(const std::string& opt_key : default_config.keys()){
ConfigOption* opt = default_config.optptr(opt_key, false);
bool is_override_key = std::find(filament_extruder_override_keys.begin(),filament_extruder_override_keys.end(), opt_key) != filament_extruder_override_keys.end();
if(!is_override_key || !opt->nullable())
continue;
opt->deserialize("nil",ForwardCompatibilitySubstitutionRule::Disable);
}
}
this->sla_materials.default_preset().config.optptr("sla_material_settings_id", true);
this->sla_materials.default_preset().compatible_printers_condition();
@@ -902,6 +911,7 @@ bool PresetBundle::import_json_presets(PresetsConfigSubstitutions & s
}
if (inherit_preset) {
new_config = inherit_preset->config;
new_config.apply(std::move(config));
} else {
// We support custom root preset now
auto inherits_config2 = dynamic_cast<ConfigOptionString *>(inherits_config);
@@ -913,8 +923,9 @@ bool PresetBundle::import_json_presets(PresetsConfigSubstitutions & s
// Find a default preset for the config. The PrintPresetCollection provides different default preset based on the "printer_technology" field.
const Preset &default_preset = collection->default_preset_for(config);
new_config = default_preset.config;
new_config.apply(std::move(config));
extend_default_config_length(new_config, default_preset.config);
}
new_config.apply(std::move(config));
Preset &preset = collection->load_preset(collection->path_from_name(name, inherit_preset == nullptr), name, std::move(new_config), false);
if (key_values.find(BBL_JSON_KEY_FILAMENT_ID) != key_values.end())