From 3043f4bba98967c20c8d2efb91c72c0bf183363a Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 13 Mar 2023 11:34:06 +0100 Subject: 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 --- .../cmakeprojectmanager/cmakebuildconfiguration.cpp | 15 +++++++++------ 1 file 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); -- cgit v1.2.1