mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 00:36:25 +08:00
Fix for #9864 - "Add Instance" with Multiple Objects Selected Causes Crash
This commit is contained in:
parent
c84c699a96
commit
237be88c23
@ -4988,7 +4988,16 @@ bool Plater::priv::can_decrease_instances(int obj_idx /*= -1*/) const
|
||||
|
||||
if (obj_idx < 0)
|
||||
obj_idx = get_selected_object_idx();
|
||||
return (0 <= obj_idx) && (obj_idx < (int)model.objects.size()) &&
|
||||
|
||||
if (obj_idx < 0) {
|
||||
if (const auto obj_ids = get_selection().get_object_idxs(); !obj_ids.empty())
|
||||
for (const size_t obj_id : obj_ids)
|
||||
if (can_decrease_instances(obj_id))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return obj_idx < (int)model.objects.size() &&
|
||||
(model.objects[obj_idx]->instances.size() > 1) &&
|
||||
!sidebar->obj_list()->has_selected_cut_object();
|
||||
}
|
||||
@ -6254,6 +6263,13 @@ void Plater::increase_instances(size_t num, int obj_idx/* = -1*/)
|
||||
if (obj_idx < 0)
|
||||
obj_idx = p->get_selected_object_idx();
|
||||
|
||||
if (obj_idx < 0) {
|
||||
if (const auto obj_idxs = get_selection().get_object_idxs(); !obj_idxs.empty())
|
||||
for (const size_t obj_id : obj_idxs)
|
||||
increase_instances(1, int(obj_id));
|
||||
return;
|
||||
}
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
ModelInstance* model_instance = model_object->instances.back();
|
||||
|
||||
@ -6289,6 +6305,13 @@ void Plater::decrease_instances(size_t num, int obj_idx/* = -1*/)
|
||||
if (obj_idx < 0)
|
||||
obj_idx = p->get_selected_object_idx();
|
||||
|
||||
if (obj_idx < 0) {
|
||||
if (const auto obj_ids = get_selection().get_object_idxs(); !obj_ids.empty())
|
||||
for (const size_t obj_id : obj_ids)
|
||||
decrease_instances(1, int(obj_id));
|
||||
return;
|
||||
}
|
||||
|
||||
ModelObject* model_object = p->model.objects[obj_idx];
|
||||
if (model_object->instances.size() > num) {
|
||||
for (size_t i = 0; i < num; ++ i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user