mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-05-25 15:47:25 +08:00
Fix of SPE-753
Slicer crash when SLA printer is selected and printer profile is changed First, there was a bug in the preset Tabs, where a "printer_technology" was incorrectly queried on "print" and "filament" (or "sla_print" and "sla_material") profiles. Second, there was an unsafe "printer_technology" getter, which would add the missing key to the config container when queried for.
This commit is contained in:
parent
40e7346696
commit
6b70f60460
@ -161,9 +161,17 @@ public:
|
|||||||
}
|
}
|
||||||
const std::string& compatible_printers_condition() const { return const_cast<Preset*>(this)->compatible_printers_condition(); }
|
const std::string& compatible_printers_condition() const { return const_cast<Preset*>(this)->compatible_printers_condition(); }
|
||||||
|
|
||||||
static PrinterTechnology& printer_technology(DynamicPrintConfig &cfg) { return cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology", true)->value; }
|
// Return a printer technology, return ptFFF if the printer technology is not set.
|
||||||
PrinterTechnology& printer_technology() { return Preset::printer_technology(this->config); }
|
static PrinterTechnology printer_technology(const DynamicPrintConfig &cfg) {
|
||||||
const PrinterTechnology& printer_technology() const { return Preset::printer_technology(const_cast<Preset*>(this)->config); }
|
auto *opt = cfg.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology");
|
||||||
|
// The following assert may trigger when importing some legacy profile,
|
||||||
|
// but it is safer to keep it here to capture the cases where the "printer_technology" key is queried, where it should not.
|
||||||
|
assert(opt != nullptr);
|
||||||
|
return (opt == nullptr) ? ptFFF : opt->value;
|
||||||
|
}
|
||||||
|
PrinterTechnology printer_technology() const { return Preset::printer_technology(this->config); }
|
||||||
|
// This call returns a reference, it may add a new entry into the DynamicPrintConfig.
|
||||||
|
PrinterTechnology& printer_technology_ref() { return this->config.option<ConfigOptionEnum<PrinterTechnology>>("printer_technology", true)->value; }
|
||||||
|
|
||||||
// Mark this preset as compatible if it is compatible with active_printer.
|
// Mark this preset as compatible if it is compatible with active_printer.
|
||||||
bool update_compatible(const Preset &active_printer, const DynamicPrintConfig *extra_config, const Preset *active_print = nullptr);
|
bool update_compatible(const Preset &active_printer, const DynamicPrintConfig *extra_config, const Preset *active_print = nullptr);
|
||||||
|
@ -81,7 +81,7 @@ PresetBundle::PresetBundle() :
|
|||||||
this->sla_prints.default_preset().inherits();
|
this->sla_prints.default_preset().inherits();
|
||||||
|
|
||||||
this->printers.add_default_preset(Preset::sla_printer_options(), static_cast<const SLAMaterialConfig&>(SLAFullPrintConfig::defaults()), "- default SLA -");
|
this->printers.add_default_preset(Preset::sla_printer_options(), static_cast<const SLAMaterialConfig&>(SLAFullPrintConfig::defaults()), "- default SLA -");
|
||||||
this->printers.preset(1).printer_technology() = ptSLA;
|
this->printers.preset(1).printer_technology_ref() = ptSLA;
|
||||||
for (size_t i = 0; i < 2; ++ i) {
|
for (size_t i = 0; i < 2; ++ i) {
|
||||||
// The following ugly switch is to avoid printers.preset(0) to return the edited instance, as the 0th default is the current one.
|
// The following ugly switch is to avoid printers.preset(0) to return the edited instance, as the 0th default is the current one.
|
||||||
Preset &preset = this->printers.default_preset(i);
|
Preset &preset = this->printers.default_preset(i);
|
||||||
|
@ -2296,11 +2296,13 @@ void Tab::load_current_preset()
|
|||||||
(preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true);
|
(preset.is_default || preset.is_system) ? m_btn_delete_preset->Disable() : m_btn_delete_preset->Enable(true);
|
||||||
|
|
||||||
update();
|
update();
|
||||||
// For the printer profile, generate the extruder pages.
|
if (m_name == "printer") {
|
||||||
if (preset.printer_technology() == ptFFF)
|
// For the printer profile, generate the extruder pages.
|
||||||
on_preset_loaded();
|
if (preset.printer_technology() == ptFFF)
|
||||||
else
|
on_preset_loaded();
|
||||||
wxGetApp().sidebar().update_objects_list_extruder_column(1);
|
else
|
||||||
|
wxGetApp().sidebar().update_objects_list_extruder_column(1);
|
||||||
|
}
|
||||||
// Reload preset pages with the new configuration values.
|
// Reload preset pages with the new configuration values.
|
||||||
reload_config();
|
reload_config();
|
||||||
|
|
||||||
@ -2325,7 +2327,7 @@ void Tab::load_current_preset()
|
|||||||
|
|
||||||
// update show/hide tabs
|
// update show/hide tabs
|
||||||
if (m_name == "printer") {
|
if (m_name == "printer") {
|
||||||
PrinterTechnology& printer_technology = m_presets->get_edited_preset().printer_technology();
|
const PrinterTechnology printer_technology = m_presets->get_edited_preset().printer_technology();
|
||||||
if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology)
|
if (printer_technology != static_cast<TabPrinter*>(this)->m_printer_technology)
|
||||||
{
|
{
|
||||||
for (auto tab : wxGetApp().tabs_list) {
|
for (auto tab : wxGetApp().tabs_list) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user