From 71e8df3107f348055d666f9e9f3d18cdfdda968b Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Fri, 21 May 2021 00:04:22 +0800 Subject: [PATCH] fix: memory leak when switching between animated image files --- app/graphicsscene.cpp | 2 +- app/mainwindow.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/graphicsscene.cpp b/app/graphicsscene.cpp index 2cb708b..4aecd6d 100644 --- a/app/graphicsscene.cpp +++ b/app/graphicsscene.cpp @@ -51,8 +51,8 @@ void GraphicsScene::showSvg(const QString &filepath) void GraphicsScene::showAnimated(const QString &filepath) { this->clear(); - QMovie * movie = new QMovie(filepath); QLabel * label = new QLabel; + QMovie * movie = new QMovie(filepath, QByteArray(), label); label->setStyleSheet("background-color:rgba(225,255,255,0);"); label->setMovie(movie); this->addWidget(label); diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index 699f2c8..009b76b 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -50,7 +50,7 @@ MainWindow::MainWindow(QWidget *parent) m_floatUpAnimation = new QPropertyAnimation(this, "geometry"); m_floatUpAnimation->setDuration(300); m_floatUpAnimation->setEasingCurve(QEasingCurve::OutCirc); - m_exitAnimationGroup = new QParallelAnimationGroup; + m_exitAnimationGroup = new QParallelAnimationGroup(this); m_exitAnimationGroup->addAnimation(m_fadeOutAnimation); m_exitAnimationGroup->addAnimation(m_floatUpAnimation); connect(m_exitAnimationGroup, &QParallelAnimationGroup::finished,