diff options
author | supermerill <merill@free.fr> | 2020-09-18 02:28:42 +0300 |
---|---|---|
committer | supermerill <merill@free.fr> | 2020-09-18 02:29:59 +0300 |
commit | df4b3c74243228f79822e77d62fe134e747133d1 (patch) | |
tree | 0bf4b34e900a2884e6098c1c652a4482fcd6d222 | |
parent | 12a30f7aa616ad431db9c150ba0862587a377e3e (diff) |
#479 bad memory usage fix (move then delete)
since march... my fault
-rw-r--r-- | src/libslic3r/PerimeterGenerator.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index df094a92c..358cd2556 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -752,7 +752,11 @@ void PerimeterGenerator::process() coll2.entities.push_back(loop); } } - entities = coll2; + //note: this hacky thing is possible because coll2.entities contains in fact entities's entities + //if you does entities = coll2, you'll delete entities's entities and then you have nothing. + entities.entities = coll2.entities; + //and you have to empty coll2 or it will delete his content, hence crashing our hack + coll2.entities.clear(); } } else if (this->config->external_perimeters_hole.value) { //reverse the hole, and put them in first place. @@ -768,13 +772,19 @@ void PerimeterGenerator::process() coll2.entities.push_back(loop); } } - entities = coll2; + //note: this hacky thing is possible because coll2.entities contains in fact entities's entities + //if you does entities = coll2, you'll delete entities's entities and then you have nothing. + entities.entities = coll2.entities; + //and you have to empty coll2 or it will delete his content, hence crashing our hack + coll2.entities.clear(); } } // append perimeters for this slice as a collection - if (!entities.empty()) - this->loops->append(entities); + if (!entities.empty()) { + //move it, to avoid to clone evrything and then delete it + this->loops->entities.emplace_back( new ExtrusionEntityCollection(std::move(entities))); + } } // for each loop of an island // fill gaps |