docker: Correctly initialize Kit during autodetection

* Added returning the Id after detecting CMake so it can be set in the autodetected kit
* Trying to keep autodetect from adding the same Qt installation twice if qmake is linked in /bin and /usr/bin
* Added FIXME for RunControlPrivate::runConfiguration as it is used after free in rare cases
* Fixed IosCompilerDetector to not just run if a device is set
* Fixed QnxCompilerDetector to not just run if a device is set
* Fixed auto-detected debuggers not being set as auto-detected, as they now can be removed from the device screen

Change-Id: Ia7772c454d70e147e4326efacc4a6a888fa26782
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2022-04-07 14:04:20 +02:00
parent aa3f467ee2
commit 2c4553366c
13 changed files with 113 additions and 54 deletions

View File

@@ -87,8 +87,6 @@ static Id defaultCMakeToolId()
return defaultTool ? defaultTool->id() : Id();
}
const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation";
class CMakeKitAspectWidget final : public KitAspectWidget
{
Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::CMakeKitAspect)
@@ -218,7 +216,7 @@ private:
CMakeKitAspect::CMakeKitAspect()
{
setObjectName(QLatin1String("CMakeKitAspect"));
setId(TOOL_ID);
setId(Constants::TOOL_ID);
setDisplayName(tr("CMake Tool"));
setDescription(tr("The CMake Tool to use when building a project with CMake.<br>"
"This setting is ignored when using other build systems."));
@@ -235,14 +233,14 @@ CMakeKitAspect::CMakeKitAspect()
Id CMakeKitAspect::id()
{
return TOOL_ID;
return Constants::TOOL_ID;
}
Id CMakeKitAspect::cmakeToolId(const Kit *k)
{
if (!k)
return {};
return Id::fromSetting(k->value(TOOL_ID));
return Id::fromSetting(k->value(Constants::TOOL_ID));
}
CMakeTool *CMakeKitAspect::cmakeTool(const Kit *k)
@@ -255,7 +253,7 @@ void CMakeKitAspect::setCMakeTool(Kit *k, const Id id)
const Id toSet = id.isValid() ? id : defaultCMakeToolId();
QTC_ASSERT(!id.isValid() || CMakeToolManager::findById(toSet), return);
if (k)
k->setValue(TOOL_ID, toSet.toSetting());
k->setValue(Constants::TOOL_ID, toSet.toSetting());
}
Tasks CMakeKitAspect::validate(const Kit *k) const

View File

@@ -65,5 +65,9 @@ const char CMAKE_BUILD_STEP_ID[] = "CMakeProjectManager.MakeStep";
// Features
const char CMAKE_FEATURE_ID[] = "CMakeProjectManager.Wizard.FeatureCMake";
// Tool
const char TOOL_ID[] = "CMakeProjectManager.CMakeKitInformation";
} // namespace Constants
} // namespace CMakeProjectManager

View File

@@ -37,6 +37,7 @@
#include <QDir>
#include <QJsonDocument>
#include <QJsonObject>
#include <QLoggingCategory>
#include <QRegularExpression>
#include <QSet>
#include <QUuid>
@@ -47,6 +48,9 @@ using namespace Utils;
namespace CMakeProjectManager {
static Q_LOGGING_CATEGORY(cmakeToolLog, "qtc.cmake.tool", QtWarningMsg);
const char CMAKE_INFORMATION_ID[] = "Id";
const char CMAKE_INFORMATION_COMMAND[] = "Binary";
const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName";
@@ -521,6 +525,7 @@ void CMakeTool::fetchFromCapabilities() const
m_introspection->m_didRun = true;
parseFromCapabilities(cmake.stdOut());
} else {
qCCritical(cmakeToolLog) << "Fetching capabilities failed: " << cmake.allOutput() << cmake.error();
m_introspection->m_didRun = false;
}
}

View File

@@ -180,36 +180,44 @@ void CMakeToolManager::updateDocumentation()
Core::HelpManager::registerDocumentation(docs);
}
void CMakeToolManager::autoDetectCMakeForDevice(const FilePaths &searchPaths,
QList<Id> CMakeToolManager::autoDetectCMakeForDevice(const FilePaths &searchPaths,
const QString &detectionSource,
QString *logMessage)
{
QList<Id> result;
QStringList messages{tr("Searching CMake binaries...")};
for (const FilePath &path : searchPaths) {
const FilePath cmake = path.pathAppended("cmake").withExecutableSuffix();
if (cmake.isExecutableFile()) {
registerCMakeByPath(cmake, detectionSource);
const Id currentId = registerCMakeByPath(cmake, detectionSource);
if (currentId.isValid())
result.push_back(currentId);
messages.append(tr("Found \"%1\"").arg(cmake.toUserOutput()));
}
}
if (logMessage)
*logMessage = messages.join('\n');
return result;
}
void CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath, const QString &detectionSource)
Id CMakeToolManager::registerCMakeByPath(const FilePath &cmakePath, const QString &detectionSource)
{
const Id id = Id::fromString(cmakePath.toUserOutput());
Id id = Id::fromString(cmakePath.toUserOutput());
CMakeTool *cmakeTool = findById(id);
if (cmakeTool)
return;
return cmakeTool->id();
auto newTool = std::make_unique<CMakeTool>(CMakeTool::ManualDetection, id);
newTool->setFilePath(cmakePath);
newTool->setDetectionSource(detectionSource);
newTool->setDisplayName(cmakePath.toUserOutput());
id = newTool->id();
registerCMakeTool(std::move(newTool));
return id;
}
void CMakeToolManager::removeDetectedCMake(const QString &detectionSource, QString *logMessage)

View File

@@ -63,10 +63,10 @@ public:
static void updateDocumentation();
public slots:
void autoDetectCMakeForDevice(const Utils::FilePaths &searchPaths,
QList<Utils::Id> autoDetectCMakeForDevice(const Utils::FilePaths &searchPaths,
const QString &detectionSource,
QString *logMessage);
void registerCMakeByPath(const Utils::FilePath &cmakePath,
Utils::Id registerCMakeByPath(const Utils::FilePath &cmakePath,
const QString &detectionSource);
void removeDetectedCMake(const QString &detectionSource, QString *logMessage);
void listDetectedCMake(const QString &detectionSource, QString *logMessage);