mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
Scope plugin config overrides per preset type
Replace the shared plugin_config_overrides key with print/printer/filament scoped keys so merging presets into one full config cannot clobber an edited override, letting a slicing plugin config change invalidate the slice step.
This commit is contained in:
@@ -464,3 +464,29 @@ TEST_CASE("Profile validator flags dangling and renamed preset references", "[Pr
|
||||
}
|
||||
}
|
||||
|
||||
// Each preset type stores its plugin capability overrides under its own option key. Merging the print,
|
||||
// printer and filament presets into one full config under a shared key would let the last preset applied
|
||||
// overwrite the others' overrides -- the clobber that stopped an edited slicing-pipeline (print) override
|
||||
// from reaching Print::apply's diff, so re-configuring a plugin never re-sliced. Distinct per-type keys
|
||||
// make that collision impossible; guard the scoping here.
|
||||
TEST_CASE("Plugin capability override keys are scoped per preset type", "[Preset][Plugin]")
|
||||
{
|
||||
// Pin the key names: presets and 3mf files store them verbatim, so a rename is a format change.
|
||||
CHECK(Preset::plugin_overrides_key(Preset::TYPE_PRINT) == std::string("print_plugin_config_overrides"));
|
||||
CHECK(Preset::plugin_overrides_key(Preset::TYPE_PRINTER) == std::string("printer_plugin_config_overrides"));
|
||||
CHECK(Preset::plugin_overrides_key(Preset::TYPE_FILAMENT) == std::string("filament_plugin_config_overrides"));
|
||||
|
||||
// ...and each key lives on exactly its own preset type's option list, so no two ever share a slot.
|
||||
const std::pair<Preset::Type, const std::vector<std::string>*> scopes[] = {
|
||||
{Preset::TYPE_PRINT, &Preset::print_options()},
|
||||
{Preset::TYPE_PRINTER, &Preset::printer_options()},
|
||||
{Preset::TYPE_FILAMENT, &Preset::filament_options()},
|
||||
};
|
||||
for (const auto &owner : scopes)
|
||||
for (const auto &scoped : scopes) {
|
||||
const std::string key = Preset::plugin_overrides_key(scoped.first);
|
||||
CAPTURE(owner.first, key);
|
||||
CHECK(contains(*owner.second, key) == (owner.first == scoped.first));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user