diff --git a/GUI/Model/Device/MaskItems.cpp b/GUI/Model/Device/MaskItems.cpp index 423c4a41059e9ba278e3c4e9bd8e91d573611d6c..5bd71e185f4452e5df8a40151eda0a56ffc720d7 100644 --- a/GUI/Model/Device/MaskItems.cpp +++ b/GUI/Model/Device/MaskItems.cpp @@ -511,7 +511,7 @@ void PolygonItem::setIsClosed(bool closed) QVector<PolygonPointItem*> PolygonItem::points() const { - return m_points; + return QVector<PolygonPointItem*>(m_points.begin(), m_points.end()); } void PolygonItem::addPoint(double x, double y) @@ -519,7 +519,7 @@ void PolygonItem::addPoint(double x, double y) auto* pointItem = new PolygonPointItem; pointItem->setPosX(x); pointItem->setPosY(y); - m_points.push_back(pointItem); // TODO: check whether the order of points matter + m_points.emplace_back(pointItem); // TODO: check whether the order of points matter } void PolygonItem::writeTo(QXmlStreamWriter* w) const @@ -537,7 +537,7 @@ void PolygonItem::writeTo(QXmlStreamWriter* w) const w->writeEndElement(); // polygon points - for (const auto* p : points()) { + for (const auto* p : m_points) { w->writeStartElement(Tag::PolygonPoint); p->writeTo(w); w->writeEndElement(); @@ -579,11 +579,6 @@ void PolygonItem::readFrom(QXmlStreamReader* r) } } -PolygonItem::~PolygonItem() -{ - qDeleteAll(m_points); // TODO: check this! -} - /* ------------------------------------------------------------------------- */ VerticalLineItem::VerticalLineItem() diff --git a/GUI/Model/Device/MaskItems.h b/GUI/Model/Device/MaskItems.h index 993361a7ed21c48e939af6a25ea96bef23498a35..25caa263c675d0d92574cd2bc3aa3d64bfaae358 100644 --- a/GUI/Model/Device/MaskItems.h +++ b/GUI/Model/Device/MaskItems.h @@ -118,7 +118,6 @@ private: class PolygonItem : public MaskItem { public: PolygonItem(); - ~PolygonItem(); std::unique_ptr<IShape2D> createShape(double scale) const override; bool isClosed() const; @@ -132,7 +131,7 @@ public: private: bool m_isClosed = false; - QVector<PolygonPointItem*> m_points; + OwningVector<PolygonPointItem> m_points; }; class VerticalLineItem : public MaskItem {