From 7bbd1d189650b50f82c96166fefd0fee61aba2bb Mon Sep 17 00:00:00 2001
From: enricoturri1966 <enricoturri@seznam.cz>
Date: Mon, 13 Feb 2023 08:38:30 +0100
Subject: [PATCH] Fixed crash in
 Selection::get_bounding_box_in_reference_system() when using modifiers

---
 src/slic3r/GUI/Selection.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp
index 8ecb20532..a50619e65 100644
--- a/src/slic3r/GUI/Selection.cpp
+++ b/src/slic3r/GUI/Selection.cpp
@@ -866,8 +866,11 @@ std::pair<BoundingBoxf3, Transform3d> Selection::get_bounding_box_in_reference_s
     for (unsigned int id : m_list) {
         const GLVolume& vol = *get_volume(id);
         const Transform3d vol_world_rafo = vol.world_matrix();
-        const TriangleMesh* ch = vol.convex_hull();
-        for (const stl_vertex& v : ch->its.vertices) {
+        const TriangleMesh* mesh = vol.convex_hull();
+        if (mesh == nullptr)
+            mesh = &m_model->objects[vol.object_idx()]->volumes[vol.volume_idx()]->mesh();
+        assert(mesh != nullptr);
+        for (const stl_vertex& v : mesh->its.vertices) {
             const Vec3d world_v = vol_world_rafo * v.cast<double>();
             for (int i = 0; i < 3; ++i) {
                 const double i_comp = world_v.dot(axes[i]);