From: David Kastrup <dak@gnu.org>
Date: Thu, 4 Sep 2014 15:23:51 +0000 (+0200)
Subject: Issue 4092: Limit tuplet bracket length to actual tuplet length
X-Git-Tag: release/2.19.14-1~15
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=9fd81cd1fbc2935e1c69842ed9f41294af62f504;p=lilypond.git

Issue 4092: Limit tuplet bracket length to actual tuplet length

See the regtest for an example of the problem.  Without the patch, the
tuplet bracket extends over all of

  \tuplet 3/2 4 { g16 a b } c8

including c8, resulting in visual lengths not adding up.
---

diff --git a/input/regression/tuplet-long-spanner.ly b/input/regression/tuplet-long-spanner.ly
new file mode 100644
index 0000000000..d79ac54700
--- /dev/null
+++ b/input/regression/tuplet-long-spanner.ly
@@ -0,0 +1,21 @@
+\version "2.19.14"
+
+\header {
+  texidoc = "Overlong tuplet span specifications are reduced
+to the actual length."
+}
+
+\layout { ragged-right = ##t }
+
+\relative \new Staff \with { subdivideBeams = ##t
+			     baseMoment = #(ly:make-moment 1/8)
+			   }
+{
+  \tuplet 3/2 4 { g16 a b } c8 d e f2 |
+  \set baseMoment = #(ly:make-moment 1/12)
+  \tuplet 3/2 4
+  { d16 e f g a b  c,16 d e f g a
+    \unset baseMoment
+    b, c d }
+  \tuplet 3/2 { e16 f8 } g4 |
+}
diff --git a/lily/tuplet-iterator.cc b/lily/tuplet-iterator.cc
index e04a0e9de8..20d04e651b 100644
--- a/lily/tuplet-iterator.cc
+++ b/lily/tuplet-iterator.cc
@@ -109,6 +109,8 @@ Tuplet_iterator::process (Moment m)
 
       if (m.main_part_ < music_get_length ().main_part_)
         {
+          spanner_duration_ =
+            min (music_get_length () - next_split_mom_, spanner_duration_);
           tuplet_handler_.set_context (get_outlet ());
           report_event (create_event (START));
 
@@ -128,15 +130,11 @@ Tuplet_iterator::construct_children ()
 {
   if (Duration *d = Duration::unsmob (get_music ()->get_property ("duration")))
     spanner_duration_ = d->get_length ();
+  else if (Moment *mp
+           = Moment::unsmob (get_outlet ()->get_property ("tupletSpannerDuration")))
+    spanner_duration_ = mp->main_part_;
   else
-    {
-      spanner_duration_ = music_get_length ();
-
-      Moment *mp
-        = Moment::unsmob (get_outlet ()->get_property ("tupletSpannerDuration"));
-      if (mp)
-        spanner_duration_ = min (mp->main_part_, spanner_duration_);
-    }
+    spanner_duration_.set_infinite (1);
 
   Music_wrapper_iterator::construct_children ();