mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
FIX: Fix damaged presets when loading presets
Jira: none Change-Id: I16ca340b13f31e390d63f0cb83a5fc036f7e3ab1 (cherry picked from commit f3d5873245258d05890dd0f563e0f921ad335c1f)
This commit is contained in:
@@ -1278,8 +1278,8 @@ void PresetCollection::load_presets(
|
|||||||
preset.filament_id = key_values[BBL_JSON_KEY_FILAMENT_ID];
|
preset.filament_id = key_values[BBL_JSON_KEY_FILAMENT_ID];
|
||||||
if (key_values.find(BBL_JSON_KEY_DESCRIPTION) != key_values.end())
|
if (key_values.find(BBL_JSON_KEY_DESCRIPTION) != key_values.end())
|
||||||
preset.description = key_values[BBL_JSON_KEY_DESCRIPTION];
|
preset.description = key_values[BBL_JSON_KEY_DESCRIPTION];
|
||||||
if (key_values.find("instantiation") != key_values.end())
|
if (key_values.find(BBL_JSON_KEY_INSTANTIATION) != key_values.end())
|
||||||
preset.is_visible = key_values["instantiation"] != "false";
|
preset.is_visible = key_values[BBL_JSON_KEY_INSTANTIATION] != "false";
|
||||||
|
|
||||||
//Orca: find and use the inherit config as the base
|
//Orca: find and use the inherit config as the base
|
||||||
Preset* inherit_preset = nullptr;
|
Preset* inherit_preset = nullptr;
|
||||||
@@ -1327,6 +1327,18 @@ void PresetCollection::load_presets(
|
|||||||
<< "\" contains the following incorrect keys: " << incorrect_keys << ", which were removed";
|
<< "\" contains the following incorrect keys: " << incorrect_keys << ", which were removed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (preset.type == Preset::TYPE_FILAMENT && preset.is_user() && preset.inherits().empty()) {
|
||||||
|
auto compatible_printers = dynamic_cast<ConfigOptionStrings *>(preset.config.option("compatible_printers", true));
|
||||||
|
if (compatible_printers && compatible_printers->values.empty()) {
|
||||||
|
size_t at_pos = name.find('@');
|
||||||
|
if (at_pos != std::string::npos && at_pos + 1 < name.length()) {
|
||||||
|
compatible_printers->values.push_back(name.substr(at_pos + 1));
|
||||||
|
preset.save(nullptr);
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " added compatible_printers for preset: " << name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
preset.loaded = true;
|
preset.loaded = true;
|
||||||
//BBS: add some workaround for previous incorrect settings
|
//BBS: add some workaround for previous incorrect settings
|
||||||
if ((!preset.setting_id.empty())&&(preset.setting_id == preset.base_id))
|
if ((!preset.setting_id.empty())&&(preset.setting_id == preset.base_id))
|
||||||
@@ -1356,6 +1368,7 @@ void PresetCollection::load_presets(
|
|||||||
if (fs::exists(file_path))
|
if (fs::exists(file_path))
|
||||||
fs::remove(file_path);
|
fs::remove(file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
presets_loaded.emplace_back(preset);
|
presets_loaded.emplace_back(preset);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " load config successful and preset name is:" << preset.name;
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << " load config successful and preset name is:" << preset.name;
|
||||||
} catch (const std::runtime_error &err) {
|
} catch (const std::runtime_error &err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user