fix(preset): abgeleitete User-Presets bekommen eigene P-filament_id (Issue #52)

save_current_preset() generierte eine P-ID nur bei leerem filament_id.
Von Hersteller-Presets abgeleitete Presets erben aber dessen Vendor-ID
(z.B. GFA001), wodurch sync_ams_list() auf das Vendor-Preset zurueckfiel
statt das User-Preset zu waehlen. Bedingung an Preset::save() angeglichen:
auch non-P IDs werden jetzt durch eine eigene P-ID ersetzt.

Doku (DE/EN/ES) und Version auf 2.4.0-alpha-kx3 aktualisiert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
viewit
2026-06-09 13:00:45 +02:00
committed by thysson2701
parent a409791826
commit 43eb68e299
3 changed files with 369 additions and 1 deletions

View File

@@ -2835,6 +2835,18 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
preset.config.option<ConfigOptionString>("print_settings_id", true)->value = new_name;
else if (m_type == Preset::TYPE_FILAMENT)
preset.config.option<ConfigOptionStrings>("filament_settings_id", true)->values[0] = new_name;
// Generate a unique filament_id for user presets that don't have one yet (PR #13315).
if (preset.filament_id.empty() || preset.filament_id.front() != 'P') {
boost::uuids::detail::md5 hash;
boost::uuids::detail::md5::digest_type digest;
hash.process_bytes(new_name.data(), new_name.size());
hash.get_digest(digest);
const auto char_digest = reinterpret_cast<const char *>(&digest);
std::string result;
boost::algorithm::hex(char_digest, char_digest + sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result));
preset.filament_id = "P" + result.substr(0, 7);
}
}
else if (m_type == Preset::TYPE_PRINTER)
preset.config.option<ConfigOptionString>("printer_settings_id", true)->value = new_name;
final_inherits = preset.inherits();