Fixed a memory leak in the move assignment operator in ExtrusionEntityCollection.

This commit is contained in:
Lukáš Hejl 2022-05-11 14:08:55 +02:00
parent c78ccdbb74
commit e0e34f6a53
2 changed files with 8 additions and 4 deletions

View File

@ -85,7 +85,7 @@ public:
virtual ExtrusionEntity* clone() const = 0; virtual ExtrusionEntity* clone() const = 0;
// Create a new object, initialize it with this object using the move semantics. // Create a new object, initialize it with this object using the move semantics.
virtual ExtrusionEntity* clone_move() = 0; virtual ExtrusionEntity* clone_move() = 0;
virtual ~ExtrusionEntity() {} virtual ~ExtrusionEntity() = default;
virtual void reverse() = 0; virtual void reverse() = 0;
virtual const Point& first_point() const = 0; virtual const Point& first_point() const = 0;
virtual const Point& last_point() const = 0; virtual const Point& last_point() const = 0;

View File

@ -36,9 +36,13 @@ public:
ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : entities(std::move(other.entities)), no_sort(other.no_sort) {} ExtrusionEntityCollection(ExtrusionEntityCollection &&other) : entities(std::move(other.entities)), no_sort(other.no_sort) {}
explicit ExtrusionEntityCollection(const ExtrusionPaths &paths); explicit ExtrusionEntityCollection(const ExtrusionPaths &paths);
ExtrusionEntityCollection& operator=(const ExtrusionEntityCollection &other); ExtrusionEntityCollection& operator=(const ExtrusionEntityCollection &other);
ExtrusionEntityCollection& operator=(ExtrusionEntityCollection &&other) ExtrusionEntityCollection& operator=(ExtrusionEntityCollection &&other) {
{ this->entities = std::move(other.entities); this->no_sort = other.no_sort; return *this; } this->clear();
~ExtrusionEntityCollection() { clear(); } this->entities = std::move(other.entities);
this->no_sort = other.no_sort;
return *this;
}
~ExtrusionEntityCollection() override { clear(); }
explicit operator ExtrusionPaths() const; explicit operator ExtrusionPaths() const;
bool is_collection() const override { return true; } bool is_collection() const override { return true; }