Fix problem with incorrect number of objects in object list after bedfil

fixes for problem reported in SPE-1824 (bug 2.)
This commit is contained in:
tamasmeszaros 2023-08-15 13:09:47 +02:00
parent 0c0a1af1e9
commit 62c64fce2d
2 changed files with 12 additions and 8 deletions

View File

@ -58,9 +58,15 @@ public:
typename decltype(std::declval<ArrangeTaskT>().process_native( typename decltype(std::declval<ArrangeTaskT>().process_native(
std::declval<arr2::ArrangeTaskCtl>()))::element_type; std::declval<arr2::ArrangeTaskCtl>()))::element_type;
// All callbacks are called in the main thread.
struct Callbacks { struct Callbacks {
// Task is prepared but not no processing has been initiated
std::function<void(ArrangeTaskT &)> on_prepared; std::function<void(ArrangeTaskT &)> on_prepared;
// Task has been completed but the result is not yet written (inside finalize)
std::function<void(ArrangeTaskT &)> on_processed; std::function<void(ArrangeTaskT &)> on_processed;
// Task result has been written
std::function<void(ResultType &)> on_finished; std::function<void(ResultType &)> on_finished;
}; };

View File

@ -6279,7 +6279,7 @@ void Plater::fill_bed_with_instances()
ModelObject *model_object = prototype_mi->get_object(); ModelObject *model_object = prototype_mi->get_object();
assert(model_object); assert(model_object);
// model_object->ensure_on_bed(); model_object->ensure_on_bed();
size_t inst_cnt = model_object->instances.size(); size_t inst_cnt = model_object->instances.size();
if (inst_cnt == 0) if (inst_cnt == 0)
@ -6290,19 +6290,17 @@ void Plater::fill_bed_with_instances()
if (object_idx < 0 || object_idx >= int(model().objects.size())) if (object_idx < 0 || object_idx >= int(model().objects.size()))
return; return;
int added_cnt = result.to_add.size(); update(static_cast<unsigned int>(UpdateParams::FORCE_FULL_SCREEN_REFRESH));
if (added_cnt > 0) { if (!result.to_add.empty()) {
update(static_cast<unsigned int>(UpdateParams::FORCE_FULL_SCREEN_REFRESH)); auto added_cnt = result.to_add.size();
// FIXME: somebody explain why this is needed for // FIXME: somebody explain why this is needed for
// increase_object_instances // increase_object_instances
if (inst_cnt == 1) if (result.arranged_items.size() == 1)
added_cnt++; added_cnt++;
sidebar() sidebar().obj_list()->increase_object_instances(object_idx, added_cnt);
.obj_list()
->increase_object_instances(object_idx, size_t(added_cnt));
} }
}; };