ProjectExplorer: Refactor KitManager::registerKit()

The interface of this function was rather unfortunate. In particluar,
the fact that it took ownership of the std::unique_ptr that was passed
in required some weird boiler plate code at all the calling sites.
Instead, it now becomes a proper factory function.

Change-Id: Iecdc6f6345232fc0f0a08bffaf8f1780edb57201
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Kandeler
2019-03-11 16:59:16 +01:00
parent 03d776a873
commit 3aea3a13cb
9 changed files with 89 additions and 101 deletions

View File

@@ -300,17 +300,16 @@ void IosConfigurations::updateAutomaticKitList()
kit->unblockNotification();
} else {
qCDebug(kitSetupLog) << " - Setting up new kit";
auto newKit = std::make_unique<Kit>();
kit = newKit.get();
kit->blockNotification();
kit->setAutoDetected(true);
const QString baseDisplayName = isSimulatorDeviceId(pDeviceType)
? tr("%1 Simulator").arg(qtVersion->unexpandedDisplayName())
: qtVersion->unexpandedDisplayName();
kit->setUnexpandedDisplayName(baseDisplayName);
setupKit(kit, pDeviceType, platformToolchains, debuggerId, sdk.path, qtVersion);
kit->unblockNotification();
KitManager::registerKit(std::move(newKit));
const auto init = [&](Kit *k) {
k->setAutoDetected(true);
const QString baseDisplayName = isSimulatorDeviceId(pDeviceType)
? tr("%1 Simulator").arg(qtVersion->unexpandedDisplayName())
: qtVersion->unexpandedDisplayName();
k->setUnexpandedDisplayName(baseDisplayName);
setupKit(k, pDeviceType, platformToolchains, debuggerId, sdk.path, qtVersion);
return true;
};
kit = KitManager::registerKit(init);
}
resultingKits.insert(kit);
}