diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 7d56bbe5e1..f14f1eb0a1 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -2614,6 +2614,9 @@ void PresetBundle::update_selections(AppConfig &config) break; this->filament_presets.emplace_back(remove_ini_suffix(f_name)); } + + update_filament_count(); + std::vector filament_colors; auto f_colors = config.get_printer_setting(initial_printer_profile_name, "filament_colors"); if (!f_colors.empty()) { @@ -2755,6 +2758,8 @@ void PresetBundle::load_selections(AppConfig &config, const PresetPreferences& p this->filament_presets.emplace_back(remove_ini_suffix(f_name)); } + update_filament_count(); + // Load data from AppConfig to ProjectConfig when Studio is initialized. std::vector filament_colors; auto f_colors = config.get_printer_setting(initial_printer_profile_name, "filament_colors"); @@ -3779,6 +3784,18 @@ int PresetBundle::get_printer_extruder_count() const return count; } +void PresetBundle::update_filament_count() +{ + if (printers.get_edited_preset().printer_technology() != ptFFF) + return; + const size_t num_extruders = static_cast(get_printer_extruder_count()); + if (filament_presets.size() >= num_extruders) + return; + filament_presets.resize(num_extruders, filament_presets.empty() + ? filaments.first_visible().name + : filament_presets.back()); +} + bool PresetBundle::support_different_extruders() { Preset& printer_preset = this->printers.get_edited_preset(); diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 2351084ade..220de95b78 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -372,6 +372,12 @@ public: int get_printer_extruder_count() const; bool support_different_extruders(); + // Orca: Ensure filament_presets has at least one slot per nozzle on FFF printers. + // Called from (load|update)_selections before the parallel project_config arrays + // (filament_colour/colour_type/map) are sized off filament_presets.size(), so a + // short saved filament list doesn't truncate the loaded colors. + void update_filament_count(); + // Load user configuration and store it into the user profiles. // This method is called by the configuration wizard. void load_config_from_wizard(const std::string &name, DynamicPrintConfig config, Semver file_version)