Skip to content

Commit 248cd3c

Browse files
committed
ProjectExplorer: Fix UI of various kit aspects
... when there is no value compatible with the current build device. The combo box was missing the "none" entry in that case. Amends db11237. Task-number: QTCREATORBUG-26870 Change-Id: I195b13026ac299d57287772040c1fc78ab9289d2 Reviewed-by: hjk <[email protected]>
1 parent e8383bc commit 248cd3c

File tree

5 files changed

+45
-47
lines changed

5 files changed

+45
-47
lines changed

src/plugins/cmakeprojectmanager/cmakekitaspect.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,15 @@ class CMakeToolListModel : public TreeModel<TreeItem, Internal::CMakeToolTreeIte
8080
{
8181
clear();
8282

83-
const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit);
84-
if (!dev)
85-
return;
86-
const FilePath rootPath = dev->rootPath();
87-
const QList<CMakeTool *> toolsForBuildDevice
88-
= Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) {
89-
return item->cmakeExecutable().isSameDevice(rootPath);
90-
});
91-
for (CMakeTool *item : toolsForBuildDevice)
92-
rootItem()->appendChild(new CMakeToolTreeItem(item, false));
83+
if (const IDevice::ConstPtr dev = BuildDeviceKitAspect::device(&m_kit)) {
84+
const FilePath rootPath = dev->rootPath();
85+
const QList<CMakeTool *> toolsForBuildDevice
86+
= Utils::filtered(CMakeToolManager::cmakeTools(), [rootPath](CMakeTool *item) {
87+
return item->cmakeExecutable().isSameDevice(rootPath);
88+
});
89+
for (CMakeTool *item : toolsForBuildDevice)
90+
rootItem()->appendChild(new CMakeToolTreeItem(item, false));
91+
}
9392
rootItem()->appendChild(new CMakeToolTreeItem); // The "none" item.
9493
}
9594

src/plugins/debugger/debuggerkitaspect.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,17 @@ class DebuggerItemListModel : public TreeModel<TreeItem, DebuggerTreeItem>
4848
{
4949
clear();
5050

51-
const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit);
52-
if (!device)
53-
return;
54-
const Utils::FilePath rootPath = device->rootPath();
55-
const QList<DebuggerItem> debuggersForBuildDevice
56-
= Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) {
57-
if (item.isGeneric())
58-
return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID;
59-
return item.command().isSameDevice(rootPath);
60-
});
61-
for (const DebuggerItem &item : debuggersForBuildDevice)
62-
rootItem()->appendChild(new DebuggerTreeItem(item, false));
51+
if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
52+
const Utils::FilePath rootPath = device->rootPath();
53+
const QList<DebuggerItem> debuggersForBuildDevice
54+
= Utils::filtered(DebuggerItemManager::debuggers(), [&](const DebuggerItem &item) {
55+
if (item.isGeneric())
56+
return device->id() != ProjectExplorer::Constants::DESKTOP_DEVICE_ID;
57+
return item.command().isSameDevice(rootPath);
58+
});
59+
for (const DebuggerItem &item : debuggersForBuildDevice)
60+
rootItem()->appendChild(new DebuggerTreeItem(item, false));
61+
}
6362
DebuggerItem noneItem;
6463
noneItem.setUnexpandedDisplayName(Tr::tr("None"));
6564
rootItem()->appendChild(new DebuggerTreeItem(noneItem, false));

src/plugins/projectexplorer/kitaspect.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ void KitAspect::refresh()
164164
la.spec.resetModel();
165165
la.comboBox->model()->sort(0);
166166
const QVariant itemId = la.spec.getter(*kit());
167-
la.comboBox->setCurrentIndex(la.comboBox->findData(itemId, IdRole));
167+
int idx = la.comboBox->findData(itemId, IdRole);
168+
if (idx == -1)
169+
idx = la.comboBox->count() - 1;
170+
la.comboBox->setCurrentIndex(idx);
168171
la.comboBox->setEnabled(!d->readOnly && la.comboBox->count() > 1);
169172
}
170173
}

src/plugins/projectexplorer/toolchainkitaspect.cpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,18 @@ class ToolchainListModel : public TreeModel<ToolchainTreeItem>
4040
{
4141
clear();
4242

43-
const Toolchains ltcList = ToolchainManager::toolchains(
44-
[this](const Toolchain *tc) { return m_category.contains(tc->language()); });
45-
IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit);
46-
if (!device)
47-
return;
48-
49-
const QList<Toolchain *> toolchainsForBuildDevice
50-
= Utils::filtered(ltcList, [device](Toolchain *tc) {
51-
return tc->compilerCommand().isSameDevice(device->rootPath());
52-
});
53-
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
54-
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
55-
for (const ToolchainBundle &b : bundlesForBuildDevice)
56-
rootItem()->appendChild(new ToolchainTreeItem(b));
43+
if (const IDeviceConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
44+
const Toolchains ltcList = ToolchainManager::toolchains(
45+
[this](const Toolchain *tc) { return m_category.contains(tc->language()); });
46+
const Toolchains toolchainsForBuildDevice
47+
= Utils::filtered(ltcList, [device](Toolchain *tc) {
48+
return tc->compilerCommand().isSameDevice(device->rootPath());
49+
});
50+
const QList<ToolchainBundle> bundlesForBuildDevice = ToolchainBundle::collectBundles(
51+
toolchainsForBuildDevice, ToolchainBundle::HandleMissing::CreateAndRegister);
52+
for (const ToolchainBundle &b : bundlesForBuildDevice)
53+
rootItem()->appendChild(new ToolchainTreeItem(b));
54+
}
5755
rootItem()->appendChild(new ToolchainTreeItem);
5856
}
5957

src/plugins/qtsupport/qtkitaspect.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ class QtVersionListModel : public TreeModel<TreeItem, QtVersionItem>
4949
{
5050
clear();
5151

52-
const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit);
53-
if (!device)
54-
return;
55-
const FilePath deviceRoot = device->rootPath();
56-
const QtVersions versionsForBuildDevice = QtVersionManager::versions(
57-
[&deviceRoot](const QtVersion *qt) {
58-
return qt->qmakeFilePath().isSameDevice(deviceRoot);
59-
});
60-
for (QtVersion *v : versionsForBuildDevice)
61-
rootItem()->appendChild(new QtVersionItem(v->uniqueId()));
52+
if (const IDevice::ConstPtr device = BuildDeviceKitAspect::device(&m_kit)) {
53+
const FilePath deviceRoot = device->rootPath();
54+
const QtVersions versionsForBuildDevice = QtVersionManager::versions(
55+
[&deviceRoot](const QtVersion *qt) {
56+
return qt->qmakeFilePath().isSameDevice(deviceRoot);
57+
});
58+
for (QtVersion *v : versionsForBuildDevice)
59+
rootItem()->appendChild(new QtVersionItem(v->uniqueId()));
60+
}
6261
rootItem()->appendChild(new QtVersionItem(-1)); // The "No Qt" entry.
6362
}
6463

0 commit comments

Comments
 (0)