diff --git a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp index 36f2ec9801e..f0c62a9a258 100644 --- a/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp +++ b/src/plugins/cmakeprojectmanager/cmakekitaspect.cpp @@ -80,16 +80,15 @@ public: { clear(); - const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit); - if (!dev) - return; - const FilePath rootPath = dev->rootPath(); - const QList toolsForBuildDevice - = Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) { - return item->cmakeExecutable().isSameDevice(rootPath); - }); - for (CMakeTool *item : toolsForBuildDevice) - rootItem()->appendChild(new CMakeToolTreeItem(item, false)); + if (const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit)) { + const FilePath rootPath = dev->rootPath(); + const QList toolsForBuildDevice + = Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) { + return item->cmakeExecutable().isSameDevice(rootPath); + }); + for (CMakeTool *item : toolsForBuildDevice) + rootItem()->appendChild(new CMakeToolTreeItem(item, false)); + } rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item. } diff --git a/src/plugins/debugger/debuggerkitaspect.cpp b/src/plugins/debugger/debuggerkitaspect.cpp index 00f08ac5d37..6f578828434 100644 --- a/src/plugins/debugger/debuggerkitaspect.cpp +++ b/src/plugins/debugger/debuggerkitaspect.cpp @@ -48,18 +48,17 @@ public: { clear(); - const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); - if (!device) - return; - const Utils::FilePath rootPath = device->rootPath(); - const QList debuggersForBuildDevice - = Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) { - if (item.isGeneric()) - return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID; - return item.command().isSameDevice(rootPath); - }); - for (const DebuggerItem &item : debuggersForBuildDevice) - rootItem()->appendChild(new DebuggerTreeItem(item, false)); + if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) { + const Utils::FilePath rootPath = device->rootPath(); + const QList debuggersForBuildDevice + = Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) { + if (item.isGeneric()) + return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID; + return item.command().isSameDevice(rootPath); + }); + for (const DebuggerItem &item : debuggersForBuildDevice) + rootItem()->appendChild(new DebuggerTreeItem(item, false)); + } DebuggerItem noneItem; noneItem.setUnexpandedDisplayName(Tr::tr("None")); rootItem()->appendChild(new DebuggerTreeItem(noneItem, false)); diff --git a/src/plugins/projectexplorer/kitaspect.cpp b/src/plugins/projectexplorer/kitaspect.cpp index c8fabb17792..f1fcf6b5813 100644 --- a/src/plugins/projectexplorer/kitaspect.cpp +++ b/src/plugins/projectexplorer/kitaspect.cpp @@ -164,7 +164,10 @@ void KitAspect::refresh() la.spec.resetModel(); la.comboBox->model()->sort(0); const QVariant itemId = la.spec.getter(*kit()); - la.comboBox->setCurrentIndex(la.comboBox->findData(itemId, IdRole)); + int idx = la.comboBox->findData(itemId, IdRole); + if (idx == -1) + idx = la.comboBox->count() - 1; + la.comboBox->setCurrentIndex(idx); la.comboBox->setEnabled(!d->readOnly && la.comboBox->count() > 1); } } diff --git a/src/plugins/projectexplorer/toolchainkitaspect.cpp b/src/plugins/projectexplorer/toolchainkitaspect.cpp index 657b1ab216f..d68d3b24ae8 100644 --- a/src/plugins/projectexplorer/toolchainkitaspect.cpp +++ b/src/plugins/projectexplorer/toolchainkitaspect.cpp @@ -40,20 +40,18 @@ public: { clear(); - const Toolchains ltcList = ToolchainManager::toolchains( - [this](const Toolchain *tc) { return m_category.contains(tc->language()); }); - IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit); - if (!device) - return; - - const QList toolchainsForBuildDevice - = Utils::filtered(ltcList, [device](Toolchain *tc) { - return tc->compilerCommand().isSameDevice(device->rootPath()); - }); - const QList bundlesForBuildDevice = ToolchainBundle::collectBundles( - toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister); - for (const ToolchainBundle &b : bundlesForBuildDevice) - rootItem()->appendChild(new ToolchainTreeItem(b)); + if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) { + const Toolchains ltcList = ToolchainManager::toolchains( + [this](const Toolchain *tc) { return m_category.contains(tc->language()); }); + const Toolchains toolchainsForBuildDevice + = Utils::filtered(ltcList, [device](Toolchain *tc) { + return tc->compilerCommand().isSameDevice(device->rootPath()); + }); + const QList bundlesForBuildDevice = ToolchainBundle::collectBundles( + toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister); + for (const ToolchainBundle &b : bundlesForBuildDevice) + rootItem()->appendChild(new ToolchainTreeItem(b)); + } rootItem()->appendChild(new ToolchainTreeItem); } diff --git a/src/plugins/qtsupport/qtkitaspect.cpp b/src/plugins/qtsupport/qtkitaspect.cpp index 4af43dbbf85..b232d203579 100644 --- a/src/plugins/qtsupport/qtkitaspect.cpp +++ b/src/plugins/qtsupport/qtkitaspect.cpp @@ -49,16 +49,15 @@ public: { clear(); - const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit); - if (!device) - return; - const FilePath deviceRoot = device->rootPath(); - const QtVersions versionsForBuildDevice = QtVersionManager::versions( - [&deviceRoot](const QtVersion *qt) { - return qt->qmakeFilePath().isSameDevice(deviceRoot); - }); - for (QtVersion *v : versionsForBuildDevice) - rootItem()->appendChild(new QtVersionItem(v->uniqueId())); + if (const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit)) { + const FilePath deviceRoot = device->rootPath(); + const QtVersions versionsForBuildDevice = QtVersionManager::versions( + [&deviceRoot](const QtVersion *qt) { + return qt->qmakeFilePath().isSameDevice(deviceRoot); + }); + for (QtVersion *v : versionsForBuildDevice) + rootItem()->appendChild(new QtVersionItem(v->uniqueId())); + } rootItem()->appendChild(new QtVersionItem(-1)); // The "No Qt" entry. }