aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projectimporter.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-03-11 16:59:16 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2019-03-12 10:16:33 +0000
commit3aea3a13cb43053cf0675fee2dca2cef500cde11 (patch)
treece4a4c73ec4eb9459ae6b1b257ab97f2f1944228 /src/plugins/projectexplorer/projectimporter.cpp
parent03d776a873860de71767aaf00bd13a01273afc96 (diff)
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>
Diffstat (limited to 'src/plugins/projectexplorer/projectimporter.cpp')
-rw-r--r--src/plugins/projectexplorer/projectimporter.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/plugins/projectexplorer/projectimporter.cpp b/src/plugins/projectexplorer/projectimporter.cpp
index abbc3855b1d..9cf05e0dc6c 100644
--- a/src/plugins/projectexplorer/projectimporter.cpp
+++ b/src/plugins/projectexplorer/projectimporter.cpp
@@ -286,20 +286,19 @@ bool ProjectImporter::isTemporaryKit(Kit *k) const
Kit *ProjectImporter::createTemporaryKit(const KitSetupFunction &setup) const
{
- auto k = std::make_unique<Kit>();
- Kit *kptr = k.get();
UpdateGuard guard(*this);
- {
- KitGuard kitGuard(kptr);
- k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter", "Imported Kit"));;
+ const auto init = [&](Kit *k) {
+ KitGuard kitGuard(k);
+ k->setUnexpandedDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectImporter",
+ "Imported Kit"));
k->setup();
- setup(kptr);
+ setup(k);
k->fix();
- markKitAsTemporary(kptr);
- addProject(kptr);
- } // ~KitGuard, sending kitUpdated
- KitManager::registerKit(std::move(k)); // potentially adds kits to other targetsetuppages
- return kptr;
+ markKitAsTemporary(k);
+ addProject(k);
+ return true;
+ }; // ~KitGuard, sending kitUpdated
+ return KitManager::registerKit(init); // potentially adds kits to other targetsetuppages
}
bool ProjectImporter::findTemporaryHandler(Core::Id id) const