]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3201: Don't initialize dim_cache_ array via constructor syntax
authorDavid Kastrup <dak@gnu.org>
Sat, 23 Feb 2013 08:56:06 +0000 (09:56 +0100)
committerDavid Kastrup <dak@gnu.org>
Wed, 27 Feb 2013 18:18:07 +0000 (19:18 +0100)
This is not valid C++ and not even a documented GCC extension.  It is
probabably an oversight that GCC appears to be able to interpret this
in some manner.

Also creates a custom copy constructor for Dimension_cache for the
sole purpose of being able to initialize a Dimension_cache array
element-wise from a Dimension_cache array in the copy constructor of
Grob.  C++ clearly is lacking in some departments.

lily/dimension-cache.cc
lily/grob.cc
lily/include/dimension-cache.hh

index 2d2fce49f396d2c482c329916a9a7b4ba0b9ce30..4538f17bc11a22a2646741d5a14b67de299e7e7c 100644 (file)
@@ -30,6 +30,16 @@ Dimension_cache::Dimension_cache (Dimension_cache const &d)
   extent_ = d.extent_ ? new Interval (*d.extent_) : 0;
 }
 
+Dimension_cache &
+Dimension_cache::operator = (Dimension_cache const &d)
+{
+  clear ();
+  offset_ = d.offset_ ? new Real (*d.offset_) : 0;
+  parent_ = d.parent_;
+  extent_ = d.extent_ ? new Interval (*d.extent_) : 0;
+  return *this;
+}
+
 Dimension_cache::Dimension_cache ()
 {
   init ();
index 4c54cbc508a318938b50ef5258ce012ff2f381f2..8ece3cd6f99c152a812867ab39d7967834ec6504 100644 (file)
@@ -87,13 +87,16 @@ Grob::Grob (SCM basicprops)
 }
 
 Grob::Grob (Grob const &s)
-  : dim_cache_ (s.dim_cache_)
 {
   original_ = (Grob *) & s;
   self_scm_ = SCM_EOL;
 
   immutable_property_alist_ = s.immutable_property_alist_;
   mutable_property_alist_ = SCM_EOL;
+
+  for (Axis a = X_AXIS; a < NO_AXES; incr (a))
+      dim_cache_ [a] = s.dim_cache_ [a];
+
   interfaces_ = s.interfaces_;
   object_alist_ = SCM_EOL;
 
index 581bcff8a99cc5109aa14171b01a34f7f7dabdd3..6210be1285130f886adab00c3a035d597a92b9e7 100644 (file)
@@ -36,6 +36,7 @@ class Dimension_cache
   friend class Grob;
 
   Dimension_cache (Dimension_cache const &);
+  Dimension_cache & operator = (Dimension_cache const &d);
   ~Dimension_cache ();
   Dimension_cache ();
 };