mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-12 09:17:52 -06:00
Fix of a special case in auto color print feature, which crashed with
single layer PrintObjects. Fixes Segmentation fault (GLib-GObject null pointer) #6516
This commit is contained in:
parent
221af991c2
commit
2b9e41e695
1 changed files with 7 additions and 6 deletions
|
@ -661,31 +661,32 @@ void Preview::update_layers_slider(const std::vector<double>& layers_z, bool kee
|
||||||
// if it's sign, than object have not to be a too height
|
// if it's sign, than object have not to be a too height
|
||||||
double height = object->height();
|
double height = object->height();
|
||||||
coord_t longer_side = std::max(object_x, object_y);
|
coord_t longer_side = std::max(object_x, object_y);
|
||||||
if (height / longer_side > 0.3)
|
auto num_layers = int(object->layers().size());
|
||||||
|
if (height / longer_side > 0.3 || num_layers < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const ExPolygons& bottom = object->get_layer(0)->lslices;
|
const ExPolygons& bottom = object->get_layer(0)->lslices;
|
||||||
double bottom_area = area(bottom);
|
double bottom_area = area(bottom);
|
||||||
|
|
||||||
// at least 30% of object's height have to be a solid
|
// at least 30% of object's height have to be a solid
|
||||||
size_t i;
|
int i;
|
||||||
for (i = 1; i < size_t(0.3 * object->layers().size()); i++) {
|
for (i = 1; i < int(0.3 * num_layers); ++ i) {
|
||||||
double cur_area = area(object->get_layer(i)->lslices);
|
double cur_area = area(object->get_layer(i)->lslices);
|
||||||
if (cur_area != bottom_area && fabs(cur_area - bottom_area) > scale_(scale_(1)))
|
if (cur_area != bottom_area && fabs(cur_area - bottom_area) > scale_(scale_(1)))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (i < size_t(0.3 * object->layers().size()))
|
if (i < size_t(0.3 * num_layers))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bottom layer have to be a biggest, so control relation between bottom layer and object size
|
// bottom layer have to be a biggest, so control relation between bottom layer and object size
|
||||||
double prev_area = area(object->get_layer(i)->lslices);
|
double prev_area = area(object->get_layer(i)->lslices);
|
||||||
for ( i++; i < object->layers().size(); i++) {
|
for ( i++; i < num_layers; i++) {
|
||||||
double cur_area = area(object->get_layer(i)->lslices);
|
double cur_area = area(object->get_layer(i)->lslices);
|
||||||
if (cur_area > prev_area && prev_area - cur_area > scale_(scale_(1)))
|
if (cur_area > prev_area && prev_area - cur_area > scale_(scale_(1)))
|
||||||
break;
|
break;
|
||||||
prev_area = cur_area;
|
prev_area = cur_area;
|
||||||
}
|
}
|
||||||
if (i < object->layers().size())
|
if (i < num_layers)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
double top_area = area(object->get_layer(int(object->layers().size()) - 1)->lslices);
|
double top_area = area(object->get_layer(int(object->layers().size()) - 1)->lslices);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue