diff options
author | YuSanka <yusanka@gmail.com> | 2020-08-11 16:48:49 +0300 |
---|---|---|
committer | YuSanka <yusanka@gmail.com> | 2020-08-11 16:48:49 +0300 |
commit | a6a5025a7600be41c305567ed16acfdf703194e4 (patch) | |
tree | 69a350b1af6a712ecccc0c0ef75df0062f7b4728 /src/slic3r | |
parent | f9e47b27028b7f513cea29843249894ae105ebc7 (diff) |
Fixed a crash
appeared when we try to update PlaterPresetComboBox for empty selected preset.
Diffstat (limited to 'src/slic3r')
-rw-r--r-- | src/slic3r/GUI/PresetComboBoxes.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/slic3r/GUI/PresetComboBoxes.cpp b/src/slic3r/GUI/PresetComboBoxes.cpp index 33ae4f54e..7539f3616 100644 --- a/src/slic3r/GUI/PresetComboBoxes.cpp +++ b/src/slic3r/GUI/PresetComboBoxes.cpp @@ -517,7 +517,7 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset const Preset* selected_preset = m_collection->find_preset(m_preset_bundle->filament_presets[m_extruder_idx]); // Wide icons are shown if the currently selected preset is not compatible with the current printer, // and red flag is drown in front of the selected preset. - bool wide_icons = selected_preset != nullptr && !selected_preset->is_compatible; + bool wide_icons = selected_preset && !selected_preset->is_compatible; float scale = m_em_unit*0.1f; int shifl_Left = wide_icons ? int(scale * 16 + 0.5) : 0; @@ -707,10 +707,11 @@ void PlaterPresetComboBox::update() assert(selected_filament_preset); } - const Preset& selected_preset = m_type == Preset::TYPE_FILAMENT ? *selected_filament_preset : m_collection->get_selected_preset(); + bool has_selection = m_collection->get_selected_idx() != size_t(-1); + const Preset* selected_preset = m_type == Preset::TYPE_FILAMENT ? selected_filament_preset : has_selection ? &m_collection->get_selected_preset() : nullptr; // Show wide icons if the currently selected preset is not compatible with the current printer, // and draw a red flag in front of the selected preset. - bool wide_icons = !selected_preset.is_compatible; + bool wide_icons = selected_preset && !selected_preset->is_compatible; std::map<wxString, wxBitmap*> nonsys_presets; |