mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-27 19:01:02 +00:00
Catch Only Allocation and Thread Failures Around the Shell Classification
The fallback that marks every segment as shell caught everything, which would also have hidden a logic error. It now catches what the classification can really throw on a huge print: std::bad_alloc from its grids and std::system_error from a worker thread that cannot be launched.
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <future>
|
#include <future>
|
||||||
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
@@ -1722,16 +1723,23 @@ void ViewerImpl::update_enabled_entities()
|
|||||||
// the shell is classified once per load, the first time it is needed
|
// the shell is classified once per load, the first time it is needed
|
||||||
const bool shell_reduced = reduced_mode == EReducedDetailMode::ShellOnly;
|
const bool shell_reduced = reduced_mode == EReducedDetailMode::ShellOnly;
|
||||||
if (shell_reduced && m_shell_bitset.size != m_vertices.size()) {
|
if (shell_reduced && m_shell_bitset.size != m_vertices.size()) {
|
||||||
try {
|
const auto fallback = [this]() {
|
||||||
update_shell_bitset();
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
// out of memory on a huge print: take everything for shell, which leaves out only the hidden infill
|
|
||||||
m_shell_bitset = BitSet<>(m_vertices.size());
|
m_shell_bitset = BitSet<>(m_vertices.size());
|
||||||
m_shell_bitset.setAll();
|
m_shell_bitset.setAll();
|
||||||
m_near_shell_bitset = BitSet<>(m_vertices.size());
|
m_near_shell_bitset = BitSet<>(m_vertices.size());
|
||||||
m_top_visible_bitset = BitSet<>(m_vertices.size());
|
m_top_visible_bitset = BitSet<>(m_vertices.size());
|
||||||
m_bottom_visible_bitset = BitSet<>(m_vertices.size());
|
m_bottom_visible_bitset = BitSet<>(m_vertices.size());
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
update_shell_bitset();
|
||||||
|
}
|
||||||
|
catch (const std::bad_alloc&) {
|
||||||
|
// out of memory on a huge print: take everything for shell, which leaves out only the hidden infill
|
||||||
|
fallback();
|
||||||
|
}
|
||||||
|
catch (const std::system_error&) {
|
||||||
|
// a worker thread could not be launched
|
||||||
|
fallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // ENABLE_OPENGL_ES
|
#endif // ENABLE_OPENGL_ES
|
||||||
|
|||||||
Reference in New Issue
Block a user