Skip to content

Commit

Permalink
Merge pull request #32 from Artanidos/fix_memleaks_scenario_2
Browse files Browse the repository at this point in the history
Fix mem-leak: delete menus & actions, unused Z origin label.
  • Loading branch information
Lavigne958 authored Dec 23, 2020
2 parents a957ed3 + 0ff789c commit 4b9a959
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/App/widgets/animationitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ AnimationItem::~AnimationItem()
}
delete frame;
}
delete m_contextMenu;
delete m_keyframes;
delete delAct;
delete bringToFrontAct;
Expand Down
11 changes: 8 additions & 3 deletions src/App/widgets/bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/App/widgets/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifndef BITMAP_H
#define BITMAP_H

#include <QAction>
#include <QDomElement>
#include <QImage>
#include <QObject>
Expand All @@ -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;
Expand All @@ -55,6 +57,7 @@ private slots:

private:
QImage m_image;
QAction *m_exchangeBitmapAct;

void addMenu();
};
Expand Down
2 changes: 0 additions & 2 deletions src/App/widgets/itempropertyeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/App/widgets/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/App/widgets/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/App/widgets/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Timeline::Timeline(AnimationScene *scene)

Timeline::~Timeline()
{
delete m_contextMenu;
delete m_delAct;
delete m_forwardAct;
delete m_pauseAct;
Expand Down

0 comments on commit 4b9a959

Please sign in to comment.