Load startup plugins after the presets are loaded (#17873)

* Load startup plugins after the presets are loaded

The startup plugin loads ran on the load thread while the main thread
was still starting the network and had not loaded the presets yet. A
plugin that reads the presets while it registers, such as through
full_config_value(), reached PresetBundle::full_fff_config() while
filament_presets was still empty and crashed reading filament_presets[0].
A plugin that got there a little later read the presets while
load_presets() was rebuilding them.

Start the startup loads after load_current_presets(). A printer agent
that a plugin registers after that point is already installed by the
late registration path.

Fixes #17792

* Build the full config of a bundle whose presets are not loaded yet

A new PresetBundle has no filament_presets until load_presets() runs,
and full_fff_config() read filament_presets[0] anyway, which crashed any
caller that asked for the full config before the presets loaded. Treat
such a bundle as having one filament, the edited filament preset.
This commit is contained in:
Kris Austin authored and GitHub committed 2026-11-25 14:18:45 +08:00
1 parent ce7f703e68
commit 71a1f4f6f2
3 files changed
+26 -13

No files matched your search

+3 -2
View File
@@ -5568,7 +5568,8 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
out.apply(this->project_config);
// BBS
size_t num_filaments = this->filament_presets.size();
// Before the presets load, filament_presets is empty; that bundle has one filament, the edited preset.
size_t num_filaments = std::max<size_t>(this->filament_presets.size(), 1);
std::vector<int> filament_maps = out.option<ConfigOptionInts>("filament_map")->values;
std::vector<int> filament_volume_maps(num_filaments, (int)nvtStandard);
@@ -5655,7 +5656,7 @@ DynamicPrintConfig PresetBundle::full_fff_config(bool apply_extruder, std::optio
compatible_prints_condition .emplace_back(this->filaments.get_edited_preset().compatible_prints_condition());
//BBS: add logic for settings check between different system presets
//std::string filament_inherits = this->filaments.get_edited_preset().inherits();
std::string current_preset_name = this->filament_presets[0];
std::string current_preset_name = this->filament_presets.empty() ? this->filaments.get_edited_preset().name : this->filament_presets[0];
const Preset* preset = this->filaments.find_preset(current_preset_name, true);
std::string filament_inherits = preset->inherits();
inherits .emplace_back(filament_inherits);