From 1e9164a92ef9b0014474a4aac2c2823d06db6a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 8 Sep 2022 12:56:24 +0200 Subject: [PATCH] Pass a parent pointer to the Animation instance to avoid memory leak The leak is just on termination, but we should show good practices in our examples Change-Id: I39abb7545d3c68a1a537b865ba3fcb5e60c22fbf Reviewed-by: Venugopal Shivashankar (cherry picked from commit 30947c7fd4dddd76b69a3aa11567e27174d7a3ea) Reviewed-by: Qt Cherry-pick Bot --- examples/widgets/animation/easing/animation.h | 4 ++-- examples/widgets/animation/easing/window.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/widgets/animation/easing/animation.h b/examples/widgets/animation/easing/animation.h index b6b48245830..111ad44f45f 100644 --- a/examples/widgets/animation/easing/animation.h +++ b/examples/widgets/animation/easing/animation.h @@ -15,8 +15,8 @@ public: CirclePath, NPathTypes }; - Animation(QObject *target, const QByteArray &prop) - : QPropertyAnimation(target, prop) + Animation(QObject *target, const QByteArray &prop, QObject *parent = nullptr) + : QPropertyAnimation(target, prop, parent) { setPathType(LinearPath); } diff --git a/examples/widgets/animation/easing/window.cpp b/examples/widgets/animation/easing/window.cpp index 260efa78329..11929738aed 100644 --- a/examples/widgets/animation/easing/window.cpp +++ b/examples/widgets/animation/easing/window.cpp @@ -35,7 +35,7 @@ Window::Window(QWidget *parent) m_scene.addItem(m_item); m_ui.graphicsView->setScene(&m_scene); - m_anim = new Animation(m_item, "pos"); + m_anim = new Animation(m_item, "pos", this); m_anim->setEasingCurve(QEasingCurve::OutBounce); m_ui.easingCurvePicker->setCurrentRow(int(QEasingCurve::OutBounce));