diff options
author | Brad King <brad.king@kitware.com> | 2009-10-05 20:14:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-10-05 20:14:17 (GMT) |
commit | 02f85f98c670575bf9176d2d7dacb045407dc000 (patch) | |
tree | 82bef694bb03e471097ecc446284f733196a5d8b /Source | |
parent | 08583fc58e419b6e0bb6e4026dd6724e464d25ce (diff) | |
download | CMake-02f85f98c670575bf9176d2d7dacb045407dc000.zip CMake-02f85f98c670575bf9176d2d7dacb045407dc000.tar.gz CMake-02f85f98c670575bf9176d2d7dacb045407dc000.tar.bz2 |
Target copy ctor should copy internal state
Ideally we should never copy cmTarget instances, but it is a pain to
remove current uses of it. The pimplized portion of cmTarget has mostly
members that cache results, but some are part of the object state.
These should be copied in the copy ctor instead of re-initialized.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmTarget.cxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a4f3f2f..e9bf079 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -55,6 +55,12 @@ public: { this->SourceFileFlagsConstructed = false; } + cmTargetInternals(cmTargetInternals const& r) + { + // Only some of these entries are part of the object state. + // Others not copied here are result caches. + this->SourceEntries = r.SourceEntries; + } typedef cmTarget::SourceFileFlags SourceFileFlags; std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; bool SourceFileFlagsConstructed; @@ -4354,12 +4360,12 @@ cmTargetInternalPointer::cmTargetInternalPointer() //---------------------------------------------------------------------------- cmTargetInternalPointer -::cmTargetInternalPointer(cmTargetInternalPointer const&) +::cmTargetInternalPointer(cmTargetInternalPointer const& r) { // Ideally cmTarget instances should never be copied. However until // we can make a sweep to remove that, this copy constructor avoids // allowing the resources (Internals) to be copied. - this->Pointer = new cmTargetInternals; + this->Pointer = new cmTargetInternals(*r.Pointer); } //---------------------------------------------------------------------------- @@ -4377,7 +4383,7 @@ cmTargetInternalPointer::operator=(cmTargetInternalPointer const& r) // we can make a sweep to remove that, this copy constructor avoids // allowing the resources (Internals) to be copied. cmTargetInternals* oldPointer = this->Pointer; - this->Pointer = new cmTargetInternals; + this->Pointer = new cmTargetInternals(*r.Pointer); delete oldPointer; return *this; } |