Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2019-01-10 20:08:38 +0300
committerbubnikv <bubnikv@gmail.com>2019-01-10 20:08:38 +0300
commit6b70f604607caa7ef986720b795558faaba0badb (patch)
tree6be335aa7e8a55eae1ed7bbb1e5c03259579871b /src/slic3r/GUI/Preset.hpp
parent40e7346696350ba43a530a0534ce18f0c9c6546f (diff)
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.
Diffstat (limited to 'src/slic3r/GUI/Preset.hpp')
-rw-r--r--src/slic3r/GUI/Preset.hpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/slic3r/GUI/Preset.hpp b/src/slic3r/GUI/Preset.hpp
index 24112cf10..021fea22c 100644
--- a/src/slic3r/GUI/Preset.hpp
+++ b/src/slic3r/GUI/Preset.hpp
@@ -161,9 +161,17 @@ public:
}
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; }
- PrinterTechnology& printer_technology() { return Preset::printer_technology(this->config); }
- const PrinterTechnology& printer_technology() const { return Preset::printer_technology(const_cast<Preset*>(this)->config); }
+ // Return a printer technology, return ptFFF if the printer technology is not set.
+ static PrinterTechnology printer_technology(const DynamicPrintConfig &cfg) {
+ 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.
bool update_compatible(const Preset &active_printer, const DynamicPrintConfig *extra_config, const Preset *active_print = nullptr);