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>
This commit is contained in:
parent
b68ad5ef7f
commit
257eaa6408
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <functional>
|
#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"));
|
setWindowTitle(tr("Image downloading and scaling example"));
|
||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
@ -191,6 +191,7 @@ void Images::initLayout(qsizetype count)
|
|||||||
QLayoutItem *child;
|
QLayoutItem *child;
|
||||||
while ((child = imagesLayout->takeAt(0)) != nullptr) {
|
while ((child = imagesLayout->takeAt(0)) != nullptr) {
|
||||||
child->widget()->setParent(nullptr);
|
child->widget()->setParent(nullptr);
|
||||||
|
delete child->widget();
|
||||||
delete child;
|
delete child;
|
||||||
}
|
}
|
||||||
labels.clear();
|
labels.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user