diff options
author | Remco Burema <r.burema@ultimaker.com> | 2022-04-20 21:18:39 +0300 |
---|---|---|
committer | Remco Burema <r.burema@ultimaker.com> | 2022-04-20 21:18:39 +0300 |
commit | f2a3b6fe97b1008640214c8688d17300a40c0618 (patch) | |
tree | e25359e3f2af86f016121edd5051bcdb469b91d3 | |
parent | 715f13cb69aab736aaffc4cbaff19a652c64131d (diff) |
Revert "Fix occasional crash due to unsafe threading in tree support."
This reverts commit 550d807b383104c29776f609fbe55df5ac915142.
-rw-r--r-- | src/TreeModelVolumes.cpp | 7 | ||||
-rw-r--r-- | src/TreeModelVolumes.h | 8 | ||||
-rw-r--r-- | src/TreeSupport.cpp | 5 |
3 files changed, 5 insertions, 15 deletions
diff --git a/src/TreeModelVolumes.cpp b/src/TreeModelVolumes.cpp index 1c6889ee8..7479d5a82 100644 --- a/src/TreeModelVolumes.cpp +++ b/src/TreeModelVolumes.cpp @@ -104,8 +104,6 @@ const Polygons& TreeModelVolumes::calculateCollision(const RadiusLayerPair& key) collision_areas = collision_areas.unionPolygons(collision_model.offset(radius)); } } - - const std::lock_guard<std::mutex> lock(object_mutex_); const auto ret = collision_cache_.insert({key, std::move(collision_areas)}); assert(ret.second); return ret.first->second; @@ -137,8 +135,6 @@ const Polygons& TreeModelVolumes::calculateAvoidance(const RadiusLayerPair& key) } auto avoidance_areas = getAvoidance(radius, layer_idx - 1).offset(-max_move_).smooth(5); avoidance_areas = avoidance_areas.unionPolygons(getCollision(radius, layer_idx)); - - const std::lock_guard<std::mutex> lock(object_mutex_); const auto ret = avoidance_cache_.insert({key, std::move(avoidance_areas)}); assert(ret.second); return ret.first->second; @@ -148,9 +144,8 @@ const Polygons& TreeModelVolumes::calculateInternalModel(const RadiusLayerPair& { const auto& radius = key.first; const auto& layer_idx = key.second; - const auto& internal_areas = getAvoidance(radius, layer_idx).difference(getCollision(radius, layer_idx)); - const std::lock_guard<std::mutex> lock(object_mutex_); + const auto& internal_areas = getAvoidance(radius, layer_idx).difference(getCollision(radius, layer_idx)); const auto ret = internal_model_cache_.insert({key, internal_areas}); assert(ret.second); return ret.first->second; diff --git a/src/TreeModelVolumes.h b/src/TreeModelVolumes.h index 29d23b0d6..74f2b4cc3 100644 --- a/src/TreeModelVolumes.h +++ b/src/TreeModelVolumes.h @@ -4,7 +4,6 @@ #ifndef TREEMODELVOLUMES_H #define TREEMODELVOLUMES_H -#include <mutex> #include <unordered_map> #include "settings/EnumSettings.h" //To store whether X/Y or Z distance gets priority. @@ -21,7 +20,7 @@ class Settings; /*! * \brief Lazily generates tree guidance volumes. * - * \warning This class blocks on thread access. Use calls to this in threaded blocks sparingly. + * \warning This class is not currently thread-safe and should not be accessed in OpenMP blocks */ class TreeModelVolumes { @@ -196,11 +195,6 @@ private: mutable std::unordered_map<RadiusLayerPair, Polygons> collision_cache_; mutable std::unordered_map<RadiusLayerPair, Polygons> avoidance_cache_; mutable std::unordered_map<RadiusLayerPair, Polygons> internal_model_cache_; - - /*! - * \brief Used to make the class thread-safe. - */ - mutable std::mutex object_mutex_; }; } diff --git a/src/TreeSupport.cpp b/src/TreeSupport.cpp index 278cd3e16..6edfa7f29 100644 --- a/src/TreeSupport.cpp +++ b/src/TreeSupport.cpp @@ -31,9 +31,10 @@ namespace cura { -TreeSupport::TreeSupport(const SliceDataStorage& storage) : - volumes_(storage, Application::getInstance().current_slice->scene.current_mesh_group->settings) +TreeSupport::TreeSupport(const SliceDataStorage& storage) { + const Settings& mesh_group_settings = Application::getInstance().current_slice->scene.current_mesh_group->settings; + volumes_ = TreeModelVolumes(storage, mesh_group_settings); } void TreeSupport::generateSupportAreas(SliceDataStorage& storage) |