CMakePM: Remove caching of CMakeTool

No need to cache the value of the CMakeTool, since it causes issues with
the update mechanism.

Task-number: QTCREATORBUG-29683
Change-Id: Id5925b9a90d6010aa09b4a2f7b5ed3d447f5cd7a
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Cristian Adam
2023-10-02 14:25:58 +02:00
parent 07e758147b
commit 3956d5b279

View File

@@ -247,31 +247,12 @@ void CMakeToolManager::deregisterCMakeTool(const Id &id)
CMakeTool *CMakeToolManager::defaultProjectOrDefaultCMakeTool() CMakeTool *CMakeToolManager::defaultProjectOrDefaultCMakeTool()
{ {
static CMakeTool *tool = nullptr; CMakeTool *tool = nullptr;
auto updateTool = [&] {
tool = nullptr;
if (auto bs = ProjectExplorer::ProjectTree::currentBuildSystem())
tool = CMakeKitAspect::cmakeTool(bs->target()->kit());
if (!tool)
tool = CMakeToolManager::defaultCMakeTool();
};
if (auto bs = ProjectExplorer::ProjectTree::currentBuildSystem())
tool = CMakeKitAspect::cmakeTool(bs->target()->kit());
if (!tool) if (!tool)
updateTool(); tool = CMakeToolManager::defaultCMakeTool();
QObject::connect(CMakeToolManager::instance(),
&CMakeToolManager::cmakeUpdated,
CMakeToolManager::instance(),
[&]() { updateTool(); });
QObject::connect(CMakeToolManager::instance(),
&CMakeToolManager::cmakeRemoved,
CMakeToolManager::instance(),
[&]() { updateTool(); });
QObject::connect(CMakeToolManager::instance(),
&CMakeToolManager::defaultCMakeChanged,
CMakeToolManager::instance(),
[&]() { updateTool(); });
return tool; return tool;
} }