FIX: [STUDIO-2596] import preset missing base_id

Change-Id: I2725906da26a471aef66eb8f29bf156ad00b1ec0
This commit is contained in:
chunmao.guo 2023-03-31 09:14:22 +08:00 committed by Lane.Wei
parent 483fc9f147
commit 32b6952950
2 changed files with 4 additions and 2 deletions

View file

@ -666,9 +666,10 @@ PresetsConfigSubstitutions PresetBundle::import_presets(std::vector<std::string>
DynamicPrintConfig new_config; DynamicPrintConfig new_config;
Preset * inherit_preset = nullptr; Preset * inherit_preset = nullptr;
ConfigOption *inherits_config = config.option(BBL_JSON_KEY_INHERITS); ConfigOption *inherits_config = config.option(BBL_JSON_KEY_INHERITS);
std::string inherits_value;
if (inherits_config) { if (inherits_config) {
ConfigOptionString *option_str = dynamic_cast<ConfigOptionString *>(inherits_config); ConfigOptionString *option_str = dynamic_cast<ConfigOptionString *>(inherits_config);
std::string inherits_value = option_str->value; inherits_value = option_str->value;
inherit_preset = collection->find_preset(inherits_value, false, true); inherit_preset = collection->find_preset(inherits_value, false, true);
} }
if (inherit_preset) { if (inherit_preset) {
@ -685,6 +686,7 @@ PresetsConfigSubstitutions PresetBundle::import_presets(std::vector<std::string>
Preset &preset = collection->load_preset(collection->path_from_name(name), name, std::move(new_config), false); Preset &preset = collection->load_preset(collection->path_from_name(name), name, std::move(new_config), false);
preset.is_external = true; preset.is_external = true;
preset.version = *version; preset.version = *version;
inherit_preset = collection->find_preset(inherits_value, false, true); // pointer maybe wrong after insert, redo find
if (inherit_preset) if (inherit_preset)
preset.base_id = inherit_preset->setting_id; preset.base_id = inherit_preset->setting_id;
Preset::normalize(preset.config); Preset::normalize(preset.config);

View file

@ -920,7 +920,7 @@ wxWindow* PreferencesDialog::create_general_page()
auto title_presets = create_item_title(_L("Presets"), page, _L("Presets")); auto title_presets = create_item_title(_L("Presets"), page, _L("Presets"));
auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset"); auto item_user_sync = create_item_checkbox(_L("Auto sync user presets(Printer/Filament/Process)"), page, _L("User Sync"), 50, "sync_user_preset");
auto item_system_sync = create_item_checkbox(_L("Auto sync system presets(Printer/Filament/Process)"), page, _L("System Sync"), 50, "sync_system_preset"); auto item_system_sync = create_item_checkbox(_L("Update built-in Presets automatically."), page, _L("System Sync"), 50, "sync_system_preset");
auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, _L("Clear my choice on the unsaved presets."), []() { auto item_save_presets = create_item_button(_L("Clear my choice on the unsaved presets."), _L("Clear"), page, _L("Clear my choice on the unsaved presets."), []() {
wxGetApp().app_config->set("save_preset_choise", ""); wxGetApp().app_config->set("save_preset_choise", "");
}); });