From 02f85f98c670575bf9176d2d7dacb045407dc000 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 5 Oct 2009 16:14:17 -0400 Subject: 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. --- Source/cmTarget.cxx | 12 +++++++++--- 1 file 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 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; } -- cgit v0.12