[Cmake-commits] [cmake-commits] king committed cmTarget.cxx 1.279 1.280

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Oct 5 16:14:19 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv29980/Source

Modified Files:
	cmTarget.cxx 
Log Message:
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.


Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.279
retrieving revision 1.280
diff -C 2 -d -r1.279 -r1.280
*** cmTarget.cxx	5 Oct 2009 13:06:58 -0000	1.279
--- cmTarget.cxx	5 Oct 2009 20:14:17 -0000	1.280
***************
*** 56,59 ****
--- 56,65 ----
      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;
***************
*** 4355,4364 ****
  //----------------------------------------------------------------------------
  cmTargetInternalPointer
! ::cmTargetInternalPointer(cmTargetInternalPointer const&)
  {
    // 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;
  }
  
--- 4361,4370 ----
  //----------------------------------------------------------------------------
  cmTargetInternalPointer
! ::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(*r.Pointer);
  }
  
***************
*** 4378,4382 ****
    // allowing the resources (Internals) to be copied.
    cmTargetInternals* oldPointer = this->Pointer;
!   this->Pointer = new cmTargetInternals;
    delete oldPointer;
    return *this;
--- 4384,4388 ----
    // allowing the resources (Internals) to be copied.
    cmTargetInternals* oldPointer = this->Pointer;
!   this->Pointer = new cmTargetInternals(*r.Pointer);
    delete oldPointer;
    return *this;



More information about the Cmake-commits mailing list