diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-03-10 16:40:20 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-03-13 20:03:29 +0000 |
commit | 257eaa6408aeb965ceaeee2bb61dfd65e65e3e28 (patch) | |
tree | b7c24caa9d1b18ef2c40d6985201113f3ed18ef9 | |
parent | b68ad5ef7fd8df0ef4aea03f33dfe05fd8272469 (diff) | |
download | qtbase-257eaa6408aeb965ceaeee2bb61dfd65e65e3e28.tar.gz |
Imagescaling example: fix memory leaks
* The DownloadDialog was never destroyed properly. Pass 'this' to its
constructor to fix it.
* When re-creating an image grid layout, properly clean up old image
labels in Images::initLayout()
Task-number: QTBUG-103514
Change-Id: Ief52774002632d4ad3a6cca85bb0c0aa1a1d4bc0
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
(cherry picked from commit 0ac234f9e256949cbacb77f94d39fff90caba7b4)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/qtconcurrent/imagescaling/imagescaling.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.cpp b/examples/qtconcurrent/imagescaling/imagescaling.cpp index fca9291e8b..4b19012c04 100644 --- a/examples/qtconcurrent/imagescaling/imagescaling.cpp +++ b/examples/qtconcurrent/imagescaling/imagescaling.cpp @@ -9,7 +9,7 @@ #include <functional> -Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog()) +Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog(this)) { setWindowTitle(tr("Image downloading and scaling example")); resize(800, 600); @@ -191,6 +191,7 @@ void Images::initLayout(qsizetype count) QLayoutItem *child; while ((child = imagesLayout->takeAt(0)) != nullptr) { child->widget()->setParent(nullptr); + delete child->widget(); delete child; } labels.clear(); |