diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 4cfe847c7..c57ae381f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -701,13 +701,20 @@ void Sidebar::show_info_sizer() int obj_idx = p->plater->get_selected_object_idx(); const ModelObject* model_object = (*wxGetApp().model_objects())[obj_idx]; + // hack to avoid crash when deleting the last object on the bed + if (model_object->volumes.empty()) + { + p->object_info->Show(false); + return; + } + const ModelInstance* model_instance = !model_object->instances.empty() ? model_object->instances.front() : nullptr; auto size = model_object->instance_bounding_box(0).size(); p->object_info->info_size->SetLabel(wxString::Format("%.2f x %.2f x %.2f",size(0), size(1), size(2))); p->object_info->info_materials->SetLabel(wxString::Format("%d", static_cast(model_object->materials_count()))); - auto& stats = model_object->volumes[0]->mesh.stl.stats; + auto& stats = model_object->volumes.front()->mesh.stl.stats; auto sf = model_instance->get_scaling_factor(); p->object_info->info_volume->SetLabel(wxString::Format("%.2f", stats.volume * sf(0) * sf(1) * sf(2))); p->object_info->info_facets->SetLabel(wxString::Format(_(L("%d (%d shells)")), static_cast(model_object->facets_count()), stats.number_of_parts)); @@ -2365,7 +2372,7 @@ int Plater::get_selected_object_idx() return p->get_selected_object_idx(); } -bool Plater::is_single_full_object_selection() +bool Plater::is_single_full_object_selection() const { return p->get_selection().is_single_full_object(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 9f759366a..1b2b53040 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -139,7 +139,7 @@ public: void on_config_change(const DynamicPrintConfig &config); int get_selected_object_idx(); - bool is_single_full_object_selection(); + bool is_single_full_object_selection() const; wxGLCanvas* canvas3D(); PrinterTechnology printer_technology() const;