From cb4741acc9b3d30c8c2656bf9b63b31d12f807af Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 24 Jul 2023 17:51:23 +0300 Subject: [PATCH] Fix memory leaks. --- src/app/puzzle/carousel/vpcarrousel.cpp | 6 ++++++ src/app/puzzle/carousel/vpcarrousel.h | 2 +- src/app/puzzle/layout/vplayout.cpp | 5 +++++ src/app/puzzle/layout/vplayout.h | 2 +- src/app/puzzle/layout/vpsheet.cpp | 6 ++++++ src/app/puzzle/layout/vpsheet.h | 2 +- src/libs/vwidgets/vlineedit.cpp | 2 +- 7 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index 281c1d851..a14f85257 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -71,6 +71,12 @@ VPCarrousel::VPCarrousel(const VPLayoutPtr &layout, QWidget *parent) : Refresh(); } +//--------------------------------------------------------------------------------------------------------------------- +VPCarrousel::~VPCarrousel() +{ + delete ui; +} + //--------------------------------------------------------------------------------------------------------------------- void VPCarrousel::Refresh() { diff --git a/src/app/puzzle/carousel/vpcarrousel.h b/src/app/puzzle/carousel/vpcarrousel.h index 440060080..46934c470 100644 --- a/src/app/puzzle/carousel/vpcarrousel.h +++ b/src/app/puzzle/carousel/vpcarrousel.h @@ -59,7 +59,7 @@ class VPCarrousel : public QWidget public: explicit VPCarrousel(const VPLayoutPtr &layout, QWidget *parent = nullptr); - ~VPCarrousel() override = default; + ~VPCarrousel() override; /** * @brief SetOrientation Sets the orientation to the given value and refreshes diff --git a/src/app/puzzle/layout/vplayout.cpp b/src/app/puzzle/layout/vplayout.cpp index ca23b176a..35b403a61 100644 --- a/src/app/puzzle/layout/vplayout.cpp +++ b/src/app/puzzle/layout/vplayout.cpp @@ -55,6 +55,11 @@ VPLayout::VPLayout(QUndoStack *undoStack) : } //--------------------------------------------------------------------------------------------------------------------- +VPLayout::~VPLayout() +{ + delete m_tileFactory; +} + auto VPLayout::CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr { SCASSERT(undoStack != nullptr) diff --git a/src/app/puzzle/layout/vplayout.h b/src/app/puzzle/layout/vplayout.h index 82cf706a0..4192d9d7e 100644 --- a/src/app/puzzle/layout/vplayout.h +++ b/src/app/puzzle/layout/vplayout.h @@ -45,7 +45,7 @@ class VPLayout : public QObject { Q_OBJECT // NOLINT public: - ~VPLayout() override = default; + ~VPLayout() override; static auto CreateLayout(QUndoStack *undoStack) -> VPLayoutPtr; static void AddPiece(const VPLayoutPtr &layout, const VPPiecePtr &piece); diff --git a/src/app/puzzle/layout/vpsheet.cpp b/src/app/puzzle/layout/vpsheet.cpp index 3504a3f80..dddd2fb51 100644 --- a/src/app/puzzle/layout/vpsheet.cpp +++ b/src/app/puzzle/layout/vpsheet.cpp @@ -336,6 +336,12 @@ VPSheet::VPSheet(const VPLayoutPtr &layout, QObject *parent) SetSheetSize(QSizeF(settings->GetLayoutSheetPaperWidth(), settings->GetLayoutSheetPaperHeight())); } +//--------------------------------------------------------------------------------------------------------------------- +VPSheet::~VPSheet() +{ + delete m_sceneData; +} + //--------------------------------------------------------------------------------------------------------------------- auto VPSheet::GetLayout() const -> VPLayoutPtr { diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index d75de99ce..acb4e0019 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -143,7 +143,7 @@ class VPSheet : public QObject public: explicit VPSheet(const VPLayoutPtr &layout, QObject *parent = nullptr); - ~VPSheet() override = default; + ~VPSheet() override; /** * @brief GetLayout Returns the Layout of the sheet diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index 741492db3..a90deeb8e 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -155,7 +155,7 @@ VCompleterLineEdit::VCompleterLineEdit(QWidget *parent) : VLineEdit(parent), m_model(new QStringListModel(this)) { - setCompleter(new MultiSelectCompleter()); + setCompleter(new MultiSelectCompleter(this)); completer()->setModel(m_model); completer()->setCompletionMode(QCompleter::PopupCompletion); completer()->setCaseSensitivity(Qt::CaseInsensitive);