FIX: fix the crash issue when change setting after .gcode.3mf loaded

Change-Id: I47ae6c6b14f94858ff9789ef3ed927930b611203
(cherry picked from commit ad548cdc7491fd432603c80ea2fcf151115efd10)
This commit is contained in:
lane.wei 2023-06-15 20:19:49 +08:00 committed by Lane.Wei
parent f96e60a14a
commit 0fcc235e14
2 changed files with 13 additions and 8 deletions

View file

@ -1484,13 +1484,16 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
for (auto layer : object->support_layers())
zs.push_back(layer->print_z);
}
std::sort(zs.begin(), zs.end());
//BBS: merge numerically very close Z values.
auto end_it = std::unique(zs.begin(), zs.end());
m_layer_count = (unsigned int)(end_it - zs.begin());
for (auto it = zs.begin(); it != end_it - 1; it++) {
if (abs(*it - *(it + 1)) < EPSILON)
m_layer_count--;
if (!zs.empty())
{
std::sort(zs.begin(), zs.end());
//BBS: merge numerically very close Z values.
auto end_it = std::unique(zs.begin(), zs.end());
m_layer_count = (unsigned int)(end_it - zs.begin());
for (auto it = zs.begin(); it != end_it - 1; it++) {
if (abs(*it - *(it + 1)) < EPSILON)
m_layer_count--;
}
}
}
print.throw_if_canceled();