From 1a4767cac76e0c1a11d5e28d5c7ec91872f57ddf Mon Sep 17 00:00:00 2001 From: Carl Sorensen Date: Fri, 16 Mar 2012 21:17:36 -0600 Subject: [PATCH] Autobeaming works properly with tuplet recheck (Issue 2408) When a new shortest duration is added to a beam, the beam is rechecked for desired division. Prior to this fix, the tuplet multiplication factor was ignored when calculating the duration of each note in the beam during the recheck. Fix potential memory leak in beaming-pattern::end_moment --- input/regression/autobeam-tuplet-recheck.ly | 16 ++++++++++++++++ lily/beaming-pattern.cc | 11 ++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 input/regression/autobeam-tuplet-recheck.ly diff --git a/input/regression/autobeam-tuplet-recheck.ly b/input/regression/autobeam-tuplet-recheck.ly new file mode 100644 index 0000000000..024d467651 --- /dev/null +++ b/input/regression/autobeam-tuplet-recheck.ly @@ -0,0 +1,16 @@ +\version "2.15.34" + +\header { + + texidoc = "Autobeam rechecking works properly with tuplets. +In the example, the first beat should be beamed completely together." + +} + +\relative c' { + \time 2/4 + c16 c + \times 2/3 { c8 c16 } + \times 2/3 { c8 c16 } + c16 c +} diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index f1408497cd..8f27c23ef5 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -43,7 +43,7 @@ Beam_rhythmic_element::Beam_rhythmic_element () tuplet_start_ = false; } -Beam_rhythmic_element::Beam_rhythmic_element (Moment m, int i, bool inv, +Beam_rhythmic_element::Beam_rhythmic_element (Moment m, int i, bool inv, Rational factor, bool tuplet_start) { start_moment_ = m; @@ -352,11 +352,12 @@ Beaming_pattern::start_moment (int i) const Moment Beaming_pattern::end_moment (int i) const { - Duration *dur = new Duration (2 + max (beamlet_count (i, LEFT), - beamlet_count (i, RIGHT)), - 0); + Duration dur (2 + max (beamlet_count (i, LEFT), + beamlet_count (i, RIGHT)), + 0); - return infos_.at (i).start_moment_ + dur->get_length (); + return infos_.at (i).start_moment_ + + infos_.at(i).factor_ * dur.get_length (); } bool -- 2.39.2