mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-08 16:59:05 +08:00
Updated to fix the handling of the capacity change, and removed the code I previously added to reserve upfront since it is not really needed
This commit is contained in:
parent
306b09b4f5
commit
da29408504
@ -93,9 +93,14 @@ void LinesBucketQueue::emplace_back_bucket(ExtrusionLayers &&els, const void *ob
|
||||
{
|
||||
auto oldSize = line_buckets.capacity();
|
||||
line_buckets.emplace_back(std::move(els), objPtr, offset);
|
||||
line_bucket_ptr_queue.push(&line_buckets.back());
|
||||
auto newSize = line_buckets.capacity();
|
||||
if (oldSize != newSize) { // pointers change
|
||||
// Since line_bucket_ptr_queue is storing pointers into line_buckets,
|
||||
// we need to handle the case where the capacity changes since that makes
|
||||
// the existing pointers invalid
|
||||
if (oldSize == newSize) {
|
||||
line_bucket_ptr_queue.push(&line_buckets.back());
|
||||
}
|
||||
else { // pointers change, create a new queue from scratch
|
||||
decltype(line_bucket_ptr_queue) newQueue;
|
||||
for (LinesBucket &bucket : line_buckets) { newQueue.push(&bucket); }
|
||||
std::swap(line_bucket_ptr_queue, newQueue);
|
||||
@ -224,13 +229,6 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP
|
||||
if (objs.size() <= 1 && !wtdptr) { return {}; }
|
||||
LinesBucketQueue conflictQueue;
|
||||
|
||||
// Calculate the number of required entries in the conflict queue
|
||||
// One slot is used for the FakeWipeTower and 2 slots for each object
|
||||
size_t requiredCount = 2*objs.size() + (wtdptr.has_value() ? 1 : 0);
|
||||
// Reserve the required count to guarantee that pointers inside LinesBucketQueue::line_buckets
|
||||
// are stable while we append the entries
|
||||
conflictQueue.reserve(requiredCount);
|
||||
|
||||
if (wtdptr.has_value()) { // wipe tower at 0 by default
|
||||
auto wtpaths = wtdptr.value()->getFakeExtrusionPathsFromWipeTower();
|
||||
ExtrusionLayers wtels;
|
||||
|
Loading…
x
Reference in New Issue
Block a user