forked from qt-creator/qt-creator
DeviceSettingsWidget: Don't leak QLayoutItem
According to docs for QLayout::replaceWidget(), the returned item should be either deleted or inserted somewhere else. Change-Id: I02da36dd0d3fe7de7fa04747d26ea01620349421 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -156,7 +156,7 @@ DeviceSettingsWidget::DeviceSettingsWidget()
|
|||||||
}.attachTo(scrollAreaWidget);
|
}.attachTo(scrollAreaWidget);
|
||||||
|
|
||||||
// Just a placeholder for the device name edit widget.
|
// Just a placeholder for the device name edit widget.
|
||||||
m_deviceNameEditWidget = new QWidget();
|
m_deviceNameEditWidget = new QWidget;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
Form {
|
Form {
|
||||||
@@ -341,8 +341,9 @@ void DeviceSettingsWidget::currentDeviceChanged(int index)
|
|||||||
Layouting::Column item{Layouting::noMargin()};
|
Layouting::Column item{Layouting::noMargin()};
|
||||||
device->settings()->displayName.addToLayout(item);
|
device->settings()->displayName.addToLayout(item);
|
||||||
QWidget *newEdit = item.emerge();
|
QWidget *newEdit = item.emerge();
|
||||||
m_generalFormLayout->replaceWidget(m_deviceNameEditWidget, newEdit);
|
QLayoutItem *oldItem = m_generalFormLayout->replaceWidget(m_deviceNameEditWidget, newEdit);
|
||||||
|
QTC_CHECK(oldItem);
|
||||||
|
delete oldItem;
|
||||||
delete m_deviceNameEditWidget;
|
delete m_deviceNameEditWidget;
|
||||||
m_deviceNameEditWidget = newEdit;
|
m_deviceNameEditWidget = newEdit;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user