From 2d31485c74e28cbb63adfc49efe87cc6f0d904ee Mon Sep 17 00:00:00 2001 From: MinyazevR Date: Fri, 25 Oct 2024 00:47:25 +0300 Subject: [PATCH] Fix memory leaks with LineItem --- .../robots/common/twoDModel/src/engine/items/stylusItem.cpp | 6 ++++++ .../robots/common/twoDModel/src/engine/items/stylusItem.h | 2 +- qrtranslations/fr/plugins/robots/twoDModel_fr.ts | 2 +- qrtranslations/ru/plugins/robots/twoDModel_ru.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp index 2d74e07795..b7fd4b2e73 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp +++ b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.cpp @@ -31,6 +31,11 @@ StylusItem::StylusItem(qreal x1, qreal y1) mTmpY1 = y1; } +StylusItem::~StylusItem() +{ + qDeleteAll(mAbstractListLine); +} + AbstractItem *StylusItem::clone() const { const auto cloned = new StylusItem(x1(), y1()); @@ -148,6 +153,7 @@ QDomElement StylusItem::serialize(QDomElement &parent) const void StylusItem::deserialize(const QDomElement &element) { AbstractItem::deserialize(element); + qDeleteAll(mAbstractListLine); mAbstractListLine.clear(); recalculateProperties(); diff --git a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.h b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.h index f6a25bea2f..3afd754ffa 100644 --- a/plugins/robots/common/twoDModel/src/engine/items/stylusItem.h +++ b/plugins/robots/common/twoDModel/src/engine/items/stylusItem.h @@ -27,7 +27,7 @@ class StylusItem : public ColorFieldItem public: StylusItem(qreal x1, qreal y1); - + ~StylusItem() override; AbstractItem *clone() const override; /// Creates and returns colored stylus item for 2D model palette. diff --git a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts index ba02b770fa..e46c9e2b2b 100644 --- a/qrtranslations/fr/plugins/robots/twoDModel_fr.ts +++ b/qrtranslations/fr/plugins/robots/twoDModel_fr.ts @@ -373,7 +373,7 @@ twoDModel::items::StylusItem - + Stylus (S) Stylo (S) diff --git a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts index 906288a3a2..33a9d88bf1 100644 --- a/qrtranslations/ru/plugins/robots/twoDModel_ru.ts +++ b/qrtranslations/ru/plugins/robots/twoDModel_ru.ts @@ -649,7 +649,7 @@ twoDModel::items::StylusItem - + Stylus (S) Стилус (S)