diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 0bf9c7bba..2c9a51901 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -329,7 +329,7 @@ Semver PresetBundle::get_vendor_profile_version(std::string vendor_name) std::optional PresetBundle::get_filament_by_filament_id(const std::string& filament_id) const { if (filament_id.empty()) - return {}; + return std::nullopt; // basic filament info should be same in the parent preset and child preset // so just match the filament id is enough @@ -355,7 +355,7 @@ std::optional PresetBundle::get_filament_by_filament_id(const return info; } } - return {}; + return std::nullopt; } //BBS: load project embedded presets diff --git a/src/libslic3r/PresetBundle.hpp b/src/libslic3r/PresetBundle.hpp index 8f945af70..6a9bee8ba 100644 --- a/src/libslic3r/PresetBundle.hpp +++ b/src/libslic3r/PresetBundle.hpp @@ -55,10 +55,10 @@ struct FilamentBaseInfo std::string filament_id; std::string filament_type; std::string vendor; - int nozzle_temp_range_low; - int nozzle_temp_range_high; - bool is_support; - bool is_system; + int nozzle_temp_range_low{ 220 }; + int nozzle_temp_range_high{ 220 }; + bool is_support{ false }; + bool is_system{ true }; }; // Bundle of Print + Filament + Printer presets. diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e6ec9cb70..49f2b5ae6 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2834,8 +2834,11 @@ std::map Sidebar::build_filament_ams_list(MachineObject tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.color).GetAsString(wxC2S_HTML_SYNTAX))}); tray_config.set_key_value("filament_exist", new ConfigOptionBools{tray.is_exists}); tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{}); - auto info = wxGetApp().preset_bundle->get_filament_by_filament_id(tray.setting_id); - tray_config.set_key_value("filament_is_support", new ConfigOptionBools{ info ? info->is_support : false }); + std::optional info; + if (wxGetApp().preset_bundle) { + info = wxGetApp().preset_bundle->get_filament_by_filament_id(tray.setting_id); + } + tray_config.set_key_value("filament_is_support", new ConfigOptionBools{ info.has_value() ? info->is_support : false}); for (int i = 0; i < tray.cols.size(); ++i) { tray_config.opt("filament_multi_colors")->values.push_back(into_u8(wxColour("#" + tray.cols[i]).GetAsString(wxC2S_HTML_SYNTAX))); }