summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2023-03-13 11:34:06 +0100
committerEike Ziller <eike.ziller@qt.io>2023-03-13 12:28:49 +0000
commit3043f4bba98967c20c8d2efb91c72c0bf183363a (patch)
treefd5fadc8a44bc145afc86a3af7b8776bc8b7e412
parent4d2b448541cfa44ee385c9da6249be67c90330e5 (diff)
downloadqt-creator-3043f4bba98967c20c8d2efb91c72c0bf183363a.tar.gz
CMake: Fix leak and crash
The crash could be reproduced by opening a project, clicking the "Kit Configuration" button in the build configuration, closing that dialog, opening it again, opening the settings from the "Manage" button for the CMake tools, and closing the settings dialog. The "KitAspectWidget"s are not really widgets, and by default do not get a parent, or are otherwise lifetime managed. When "they" are added to a layout, actually only their widget members are added to the GUI. When opening and closing the "Kit Configuration" dialog, the widgets were deleted, but the KitAspectWidget instances were leaked and lived on, the CMakeKitAspectWidget referencing a now deleted QComboBox, and still being connected to the CMakeToolManager's signals, which subsequented crashed when these were sent. Fixes: QTCREATORBUG-28740 Change-Id: I36db3b6596ef21cc01dc877bca92b9961c0606b9 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
-rw-r--r--src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
index 746a64050e..127e572110 100644
--- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp
@@ -665,12 +665,15 @@ void CMakeBuildSettingsWidget::kitCMakeConfiguration()
auto layout = new QGridLayout(dialog);
- kitAspect.createConfigWidget(m_buildSystem->kit())
- ->addToLayoutWithLabel(layout->parentWidget());
- generatorAspect.createConfigWidget(m_buildSystem->kit())
- ->addToLayoutWithLabel(layout->parentWidget());
- configurationKitAspect.createConfigWidget(m_buildSystem->kit())
- ->addToLayoutWithLabel(layout->parentWidget());
+ KitAspectWidget *widget = kitAspect.createConfigWidget(m_buildSystem->kit());
+ widget->setParent(dialog);
+ widget->addToLayoutWithLabel(layout->parentWidget());
+ widget = generatorAspect.createConfigWidget(m_buildSystem->kit());
+ widget->setParent(dialog);
+ widget->addToLayoutWithLabel(layout->parentWidget());
+ widget = configurationKitAspect.createConfigWidget(m_buildSystem->kit());
+ widget->setParent(dialog);
+ widget->addToLayoutWithLabel(layout->parentWidget());
layout->setColumnStretch(1, 1);