Skip to content

Commit

Permalink
Imagescaling example: fix memory leaks
Browse files Browse the repository at this point in the history
* 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
Pick-to: 6.5 6.5.0
Change-Id: Ief52774002632d4ad3a6cca85bb0c0aa1a1d4bc0
Reviewed-by: Mårten Nordheim <[email protected]>
Reviewed-by: Jarek Kobus <[email protected]>
  • Loading branch information
isolovev committed Mar 13, 2023
1 parent 441993a commit 0ac234f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion examples/qtconcurrent/imagescaling/imagescaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <functional>

Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog())
Images::Images(QWidget *parent) : QWidget(parent), downloadDialog(new DownloadDialog(this))
{
resize(800, 600);

Expand Down Expand Up @@ -189,6 +189,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();
Expand Down

0 comments on commit 0ac234f

Please sign in to comment.