CMake: Use unique_ptr to store CMakeTools in CMakeToolManager

Change-Id: I4dfb76b40e22da745b80c359d544fa2b6d3dac52
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Tobias Hunger
2018-06-29 15:06:17 +02:00
parent 3548bf7773
commit 58ebcbe0ec
3 changed files with 67 additions and 71 deletions

View File

@@ -281,13 +281,11 @@ void CMakeToolItemModel::apply()
foreach (CMakeToolTreeItem *item, toRegister) {
CMakeTool::Detection detection = item->m_autodetected ? CMakeTool::AutoDetection
: CMakeTool::ManualDetection;
CMakeTool *cmake = new CMakeTool(detection, item->m_id);
auto cmake = std::make_unique<CMakeTool>(detection, item->m_id);
cmake->setDisplayName(item->m_name);
cmake->setCMakeExecutable(item->m_executable);
if (!CMakeToolManager::registerCMakeTool(cmake)) {
if (!CMakeToolManager::registerCMakeTool(std::move(cmake)))
item->m_changed = true;
delete cmake;
}
}
CMakeToolManager::setDefaultCMakeTool(defaultItemId());