mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-15 10:47:50 -06:00
Fix of Segfault moving support blocker #1506
Fixed unsafe access to support layers from the G-code preview UI.
This commit is contained in:
parent
8515852efc
commit
713ec1f065
1 changed files with 15 additions and 20 deletions
|
@ -685,29 +685,24 @@ void Preview::load_print_as_fff()
|
||||||
// we require that there's at least one object and the posSlice step
|
// we require that there's at least one object and the posSlice step
|
||||||
// is performed on all of them(this ensures that _shifted_copies was
|
// is performed on all of them(this ensures that _shifted_copies was
|
||||||
// populated and we know the number of layers)
|
// populated and we know the number of layers)
|
||||||
unsigned int n_layers = 0;
|
bool has_layers = false;
|
||||||
const Print *print = m_process->fff_print();
|
const Print *print = m_process->fff_print();
|
||||||
if (print->is_step_done(posSlice))
|
if (print->is_step_done(posSlice)) {
|
||||||
{
|
|
||||||
std::set<float> zs;
|
|
||||||
for (const PrintObject* print_object : print->objects())
|
for (const PrintObject* print_object : print->objects())
|
||||||
{
|
if (! print_object->layers().empty()) {
|
||||||
const LayerPtrs& layers = print_object->layers();
|
has_layers = true;
|
||||||
const SupportLayerPtrs& support_layers = print_object->support_layers();
|
break;
|
||||||
for (const Layer* layer : layers)
|
|
||||||
{
|
|
||||||
zs.insert(layer->print_z);
|
|
||||||
}
|
}
|
||||||
for (const SupportLayer* layer : support_layers)
|
}
|
||||||
{
|
if (print->is_step_done(posSupportMaterial)) {
|
||||||
zs.insert(layer->print_z);
|
for (const PrintObject* print_object : print->objects())
|
||||||
|
if (! print_object->support_layers().empty()) {
|
||||||
|
has_layers = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
n_layers = (unsigned int)zs.size();
|
if (! has_layers)
|
||||||
}
|
|
||||||
|
|
||||||
if (n_layers == 0)
|
|
||||||
{
|
{
|
||||||
reset_sliders();
|
reset_sliders();
|
||||||
m_canvas->reset_legend_texture();
|
m_canvas->reset_legend_texture();
|
||||||
|
@ -761,8 +756,8 @@ void Preview::load_print_as_fff()
|
||||||
show_hide_ui_elements("full");
|
show_hide_ui_elements("full");
|
||||||
|
|
||||||
// recalculates zs and update sliders accordingly
|
// recalculates zs and update sliders accordingly
|
||||||
n_layers = (unsigned int)m_canvas->get_current_print_zs(true).size();
|
has_layers = ! m_canvas->get_current_print_zs(true).empty();
|
||||||
if (n_layers == 0)
|
if (! has_layers)
|
||||||
{
|
{
|
||||||
// all layers filtered out
|
// all layers filtered out
|
||||||
reset_sliders();
|
reset_sliders();
|
||||||
|
@ -777,7 +772,7 @@ void Preview::load_print_as_fff()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (n_layers > 0)
|
if (has_layers)
|
||||||
update_sliders(m_canvas->get_current_print_zs(true));
|
update_sliders(m_canvas->get_current_print_zs(true));
|
||||||
|
|
||||||
m_loaded = true;
|
m_loaded = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue