From 0ff789c4c0885f2c40578c945e0b779cc6fbb13b Mon Sep 17 00:00:00 2001 From: Alexandre Lavigne Date: Tue, 22 Dec 2020 23:40:50 +0100 Subject: [PATCH] Fix mem-leak: delete menus & actions, unused Z origin label. --- src/App/widgets/animationitem.cpp | 1 + src/App/widgets/bitmap.cpp | 11 ++++++++--- src/App/widgets/bitmap.h | 3 +++ src/App/widgets/itempropertyeditor.cpp | 2 -- src/App/widgets/text.cpp | 6 ++++++ src/App/widgets/text.h | 1 + src/App/widgets/timeline.cpp | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/App/widgets/animationitem.cpp b/src/App/widgets/animationitem.cpp index d4122d1..64e0d27 100644 --- a/src/App/widgets/animationitem.cpp +++ b/src/App/widgets/animationitem.cpp @@ -87,6 +87,7 @@ AnimationItem::~AnimationItem() } delete frame; } + delete m_contextMenu; delete m_keyframes; delete delAct; delete bringToFrontAct; diff --git a/src/App/widgets/bitmap.cpp b/src/App/widgets/bitmap.cpp index dba9489..3c307e6 100644 --- a/src/App/widgets/bitmap.cpp +++ b/src/App/widgets/bitmap.cpp @@ -50,11 +50,16 @@ Bitmap::Bitmap(QImage image, AnimationScene *scene) addMenu(); } +Bitmap::~Bitmap() +{ + delete m_exchangeBitmapAct; +} + void Bitmap::addMenu() { - QAction *exchangeBitmapAct = new QAction("Exchange Bitmap"); - connect(exchangeBitmapAct, SIGNAL(triggered()), this, SLOT(exchangeBitmapAction())); - m_contextMenu->addAction(exchangeBitmapAct); + m_exchangeBitmapAct = new QAction("Exchange Bitmap"); + connect(m_exchangeBitmapAct, SIGNAL(triggered()), this, SLOT(exchangeBitmapAction())); + m_contextMenu->addAction(m_exchangeBitmapAct); } void Bitmap::exchangeBitmapAction() diff --git a/src/App/widgets/bitmap.h b/src/App/widgets/bitmap.h index 31a6fc0..07c113b 100644 --- a/src/App/widgets/bitmap.h +++ b/src/App/widgets/bitmap.h @@ -21,6 +21,7 @@ #ifndef BITMAP_H #define BITMAP_H +#include #include #include #include @@ -38,6 +39,7 @@ class Bitmap : public AnimationItem Bitmap(); Bitmap(QString filename, AnimationScene *scene); Bitmap(QImage img, AnimationScene *scene); + ~Bitmap(); void paint( QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *); QString getHtml(QString id, QString assetsPath) Q_DECL_OVERRIDE; @@ -55,6 +57,7 @@ private slots: private: QImage m_image; + QAction *m_exchangeBitmapAct; void addMenu(); }; diff --git a/src/App/widgets/itempropertyeditor.cpp b/src/App/widgets/itempropertyeditor.cpp index f1ba2a8..3f4897e 100644 --- a/src/App/widgets/itempropertyeditor.cpp +++ b/src/App/widgets/itempropertyeditor.cpp @@ -125,14 +125,12 @@ ItemPropertyEditor::ItemPropertyEditor(Timeline *timeline) QLabel *labelOrig = new QLabel("Origin"); QLabel *labelOrigX = new QLabel("X"); QLabel *labelOrigY = new QLabel("Y"); - QLabel *labelOrigZ = new QLabel("Z"); labelScaleX->setFixedWidth(15); labelScaleY->setFixedWidth(15); labelShearX->setFixedWidth(15); labelShearY->setFixedWidth(15); labelOrigX->setFixedWidth(15); labelOrigY->setFixedWidth(15); - labelOrigZ->setFixedWidth(15); m_scaleX = new QSpinBox(); m_scaleX->setMinimum(-10000); m_scaleX->setMaximum(10000); diff --git a/src/App/widgets/text.cpp b/src/App/widgets/text.cpp index 4b915a1..6ff3f4e 100644 --- a/src/App/widgets/text.cpp +++ b/src/App/widgets/text.cpp @@ -87,6 +87,12 @@ Text::Text(QString text, AnimationScene *scene) setRect(0, 0, m_svg->boundingRect().width(), m_svg->boundingRect().height()); } +Text::~Text() +{ + delete m_renderer; + delete m_svg; +} + int Text::type() const { return Text::Type; diff --git a/src/App/widgets/text.h b/src/App/widgets/text.h index 6081054..97bb9b7 100644 --- a/src/App/widgets/text.h +++ b/src/App/widgets/text.h @@ -43,6 +43,7 @@ class Text : public AnimationItem public: Text(QString text, AnimationScene *scene); + ~Text(); void paint( QPainter *paint, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE; void scaleObjects() Q_DECL_OVERRIDE; diff --git a/src/App/widgets/timeline.cpp b/src/App/widgets/timeline.cpp index 8f86246..b593d6b 100644 --- a/src/App/widgets/timeline.cpp +++ b/src/App/widgets/timeline.cpp @@ -130,6 +130,7 @@ Timeline::Timeline(AnimationScene *scene) Timeline::~Timeline() { + delete m_contextMenu; delete m_delAct; delete m_forwardAct; delete m_pauseAct;