diff options
author | Tim Jenssen <tim.jenssen@qt.io> | 2016-12-08 22:31:43 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@qt.io> | 2016-12-12 10:20:35 +0000 |
commit | b91632e642e738294acaf30a9e80a27b70d0471d (patch) | |
tree | 24d72a42e7ee671a3ca6b972f92cd87c6fa4d91f /src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp | |
parent | a08a4a4842ab58f378197f74b510d3f92ca7d921 (diff) | |
download | qt-creator-b91632e642e738294acaf30a9e80a27b70d0471d.tar.gz |
CMake: fix crash while clicking context menu
It crashed if the root project had some error
and I tried to build a subproject.
Change-Id: I13dc620402a5f79e507e7da3fedb5eb09a4112da
Reviewed-by: Alexander Drozdov <adrozdoff@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 6febf97b00..96224f009c 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -112,15 +112,17 @@ void CMakeProjectPlugin::updateContextActions(ProjectExplorer::Node *node, ProjectExplorer::Project *project) { CMakeTargetNode *targetNode = dynamic_cast<CMakeTargetNode *>(node); + // as targetNode can be deleted while the menu is open, we keep only the + const QString targetDisplayName = targetNode ? targetNode->displayName() : QString(); CMakeProject *cmProject = dynamic_cast<CMakeProject *>(project); // Build Target: disconnect(m_buildTargetContextAction); - m_buildTargetContextAction->setParameter(targetNode ? targetNode->displayName() : QString()); + m_buildTargetContextAction->setParameter(targetDisplayName); m_buildTargetContextAction->setEnabled(targetNode); m_buildTargetContextAction->setVisible(targetNode); if (cmProject && targetNode) { connect(m_buildTargetContextAction, &Utils::ParameterAction::triggered, - cmProject, [cmProject, targetNode]() { cmProject->buildCMakeTarget(targetNode->displayName()); }); + cmProject, [cmProject, targetDisplayName]() { cmProject->buildCMakeTarget(targetDisplayName); }); } } |