QStackedLayout: fix a memory leak
A layout takes ownership of the QLayoutItem passed to addItem. Change-Id: Iea3c64453f3cbf4f1b5660e505c1a35dca537833 Pick-to: 6.0 5.15 5.12 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
910203afb4
commit
1fcc882d7c
@ -44,6 +44,8 @@
|
||||
#include "private/qwidget_p.h"
|
||||
#include "private/qlayoutengine_p.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QStackedLayoutPrivate : public QLayoutPrivate
|
||||
@ -421,13 +423,13 @@ int QStackedLayout::count() const
|
||||
*/
|
||||
void QStackedLayout::addItem(QLayoutItem *item)
|
||||
{
|
||||
std::unique_ptr<QLayoutItem> guard(item);
|
||||
QWidget *widget = item->widget();
|
||||
if (Q_UNLIKELY(!widget)) {
|
||||
qWarning("QStackedLayout::addItem: Only widgets can be added");
|
||||
return;
|
||||
}
|
||||
addWidget(widget);
|
||||
delete item;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user