QStackedLayout: fix a memory leak
A layout takes ownership of the QLayoutItem passed to addItem. Change-Id: Iea3c64453f3cbf4f1b5660e505c1a35dca537833 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 1fcc882d7ca564f17e49b8d51adc43eb5b97c57b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e2c0cc9bb3
commit
c4748f909c
@ -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…
x
Reference in New Issue
Block a user