diff options
author | Christian Kandeler <[email protected]> | 2019-05-08 13:51:07 +0200 |
---|---|---|
committer | Christian Kandeler <[email protected]> | 2019-05-08 12:22:45 +0000 |
commit | f436448173df4511777d59f896217748468ea8ed (patch) | |
tree | d83f804cbda82ba030310179110924175f32b310 | |
parent | 1b2701205c2519a6ba718a835e9778e32f3c9fbd (diff) |
ProjectExplorer: Factor out common parts of Kit::{clone(), copyFrom()}
It's annoying having to update both functions whenever new members are
added.
Change-Id: I799e9f542974095dc5e5f41ece3e037e5d2acd6c
Reviewed-by: hjk <[email protected]>
-rw-r--r-- | src/plugins/projectexplorer/kit.cpp | 29 | ||||
-rw-r--r-- | src/plugins/projectexplorer/kit.h | 1 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index 754b0da6c9b..7d6fe5603d8 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -200,41 +200,40 @@ void Kit::unblockNotification() kitUpdated(); } +void Kit::copyKitCommon(Kit *target, const Kit *source) +{ + target->d->m_data = source->d->m_data; + target->d->m_iconPath = source->d->m_iconPath; + target->d->m_deviceTypeForIcon = source->d->m_deviceTypeForIcon; + target->d->m_cachedIcon = source->d->m_cachedIcon; + target->d->m_sticky = source->d->m_sticky; + target->d->m_mutable = source->d->m_mutable; + target->d->m_irrelevantAspects = source->d->m_irrelevantAspects; +} + Kit *Kit::clone(bool keepName) const { auto k = new Kit; + copyKitCommon(k, this); if (keepName) k->d->m_unexpandedDisplayName = d->m_unexpandedDisplayName; else k->d->m_unexpandedDisplayName = newKitName(KitManager::kits()); k->d->m_autodetected = false; - k->d->m_data = d->m_data; // Do not clone m_fileSystemFriendlyName, needs to be unique - k->d->m_hasError = d->m_hasError; - k->d->m_cachedIcon = d->m_cachedIcon; - k->d->m_iconPath = d->m_iconPath; - k->d->m_deviceTypeForIcon = d->m_deviceTypeForIcon; - k->d->m_sticky = d->m_sticky; - k->d->m_mutable = d->m_mutable; - k->d->m_irrelevantAspects = d->m_irrelevantAspects; + k->d->m_hasError = d->m_hasError; // TODO: Is this intentionally not done for copyFrom()? return k; } void Kit::copyFrom(const Kit *k) { KitGuard g(this); - d->m_data = k->d->m_data; - d->m_iconPath = k->d->m_iconPath; - d->m_deviceTypeForIcon = k->d->m_deviceTypeForIcon; - d->m_cachedIcon = k->d->m_cachedIcon; + copyKitCommon(this, k); d->m_autodetected = k->d->m_autodetected; d->m_autoDetectionSource = k->d->m_autoDetectionSource; d->m_unexpandedDisplayName = k->d->m_unexpandedDisplayName; d->m_fileSystemFriendlyName = k->d->m_fileSystemFriendlyName; d->m_mustNotify = true; - d->m_sticky = k->d->m_sticky; - d->m_mutable = k->d->m_mutable; - d->m_irrelevantAspects = k->d->m_irrelevantAspects; } bool Kit::isValid() const diff --git a/src/plugins/projectexplorer/kit.h b/src/plugins/projectexplorer/kit.h index a6c5f49cabf..dfdf477107c 100644 --- a/src/plugins/projectexplorer/kit.h +++ b/src/plugins/projectexplorer/kit.h @@ -142,6 +142,7 @@ public: static QString newKitName(const QString &name, const QList<Kit *> &allKits); private: + static void copyKitCommon(Kit *target, const Kit *source); void setSdkProvided(bool sdkProvided); // Unimplemented. |