From: David Kastrup Date: Sat, 23 Feb 2013 08:56:06 +0000 (+0100) Subject: Issue 3201: Don't initialize dim_cache_ array via constructor syntax X-Git-Tag: release/2.17.14-1~18 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=22581154dd1af254e4b9113e04b620d6e7c99296;p=lilypond.git Issue 3201: Don't initialize dim_cache_ array via constructor syntax 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. --- diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 2d2fce49f3..4538f17bc1 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -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 (); diff --git a/lily/grob.cc b/lily/grob.cc index 4c54cbc508..8ece3cd6f9 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -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; diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index 581bcff8a9..6210be1285 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -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 (); };