mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-13 07:23:03 +00:00
Refactor: move Printer dependencies data validation from Preset to Tab (#12026)
# Description When creating a new filament preset and setting the Printer Dependencies to "All", the preset does not save this setting. This issue only occurs on creation due to code that is meant to validate the data to prevent a case where the filament is compatible with none of the printers. EDIT: While I considered redoing the data validation for this tab overall, I have now preserved the original purpose of the code, which is to add the current printer as a compatible printer only if: - the base preset is a System preset - the user has not specified any compatible printers Notably, this seems to be the cause of #11959 Moving the data validation from `Preset::save_current_preset` to `Tab::save_preset` allows the Preset function to be simplified through removal of the current printer parameter. # Screenshots/Recordings/Graphs There is no visible change on the UI. ## Tests Tested the following combinations of filament presets: - System->new User - User->new User - User->same User Tried to set them to All, where the System->new User should be the only case where this is replaced by a default. In any case where there are printers already set, those settings should be kept.
This commit is contained in:
@@ -2422,7 +2422,7 @@ std::map<std::string, std::vector<Preset const *>> PresetCollection::get_filamen
|
||||
}
|
||||
|
||||
//BBS: add project embedded preset logic
|
||||
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset, const Preset* _current_printer)
|
||||
void PresetCollection::save_current_preset(const std::string &new_name, bool detach, bool save_to_project, Preset* _curr_preset)
|
||||
{
|
||||
Preset curr_preset = _curr_preset ? *_curr_preset : m_edited_preset;
|
||||
//BBS: add lock logic for sync preset in background
|
||||
@@ -2490,13 +2490,6 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
|
||||
} else if (is_base_preset(preset)) {
|
||||
inherits = old_name;
|
||||
}
|
||||
// Orca: check if compatible_printers exists and is not empty, set it to the current printer if it is empty
|
||||
if (nullptr != _current_printer && preset.is_system && m_type == Preset::TYPE_FILAMENT) {
|
||||
ConfigOptionStrings* compatible_printers = preset.config.option<ConfigOptionStrings>("compatible_printers");
|
||||
if (compatible_printers && compatible_printers->values.empty()) {
|
||||
compatible_printers->values.push_back(_current_printer->name);
|
||||
}
|
||||
}
|
||||
|
||||
preset.is_default = false;
|
||||
preset.is_system = false;
|
||||
|
||||
Reference in New Issue
Block a user