From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Tue, 19 Nov 2002 12:23:30 +0000 (+0000)
Subject: (warning): better robustness fix.
X-Git-Tag: release/1.7.8~1
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=73e40a0dd515fd996ee0918dd96b42a754f623d5;p=lilypond.git

(warning): better robustness fix.
---

diff --git a/ChangeLog b/ChangeLog
index 4e59cb531a..133842e9da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2002-11-19  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+	* lily/grob.cc (warning): better robustness fix.
+
+2002-11-19 Juergen Reuter  <reuter@ipd.uka.de>
+
+	* lily/cluster-engraver.cc: bugfix: use protected scm upon columns
+
+	* lily/cluster-engraver.cc: stick better to variable naming
+	conventions
+
+	* lily/cluster-engraver.cc: bugfix: delay typesetting of cluster
+	until stop_translation_timestep()
+
+	* lily/cluster-engraver.cc, lily/cluster.cc: design fix: pass
+	min/max coordinates to backend, but no musical info such as
+	pitches
+
+	* lily/cluster.cc: robustness fix: do not crash upon empty cluster
+
+	* lily/grob.cc: robustness fix: warning(): do not crash if
+	cause is not set
+
+	* lily/ligature-bracket-engraver.cc, scm/grob-description.scm: use
+	the much more elaborated tuplet brackets than the very naive and
+	simple ligature bracket grob
+
 2002-11-19  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
 	* Documentation/user/refman.itely (Analysis brackets): add
@@ -63,6 +90,8 @@
 	
 	* input/*.ly: update syntax to 1.7 + new-chords.
 
+	* VERSION: 1.7.7 released.
+	
 	* Documentation/user/*.tely: new chord syntax.
 
 	* input/regression/[bc]*.ly (texidoc): syntax updates.
diff --git a/VERSION b/VERSION
index dceff6e1c3..60fe3bf00f 100644
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=7
-PATCH_LEVEL=7
+PATCH_LEVEL=8
 MY_PATCH_LEVEL=
 
 # Use the above to send patches: MY_PATCH_LEVEL is always empty for a
diff --git a/aclocal.m4 b/aclocal.m4
index c396de57f8..e62adcde37 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,6 +1,6 @@
 dnl aclocal.m4   -*-shell-script-*-
 dnl WARNING WARNING WARNING
-dnl do not edit! this is aclocal.m4, generated from /home/fred/lily/stepmake/aclocal.m4
+dnl do not edit! this is aclocal.m4, generated from /users/hanwen/usr/src/lilypond/stepmake/aclocal.m4
 dnl aclocal.m4   -*-shell-script-*-
 dnl StepMake subroutines for configure.in
 
diff --git a/autogen.sh b/autogen.sh
index f70572727e..36d6b4939f 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -1,7 +1,4 @@
 #!/bin/sh
-# WARNING WARNING WARNING
-# do not edit! this is autogen.sh, generated from /home/fred/lily/stepmake/autogen.sh
-#!/bin/sh
 # Run this to generate configure and initial GNUmakefiles
 
 srcdir=`dirname $0`
diff --git a/lily/cluster-engraver.cc b/lily/cluster-engraver.cc
index a9bd545314..4308326c53 100644
--- a/lily/cluster-engraver.cc
+++ b/lily/cluster-engraver.cc
@@ -8,6 +8,7 @@
 #include "item.hh"
 #include "spanner.hh"
 #include "note-head.hh"
+#include "protected-scm.hh"
 #include "warn.hh"
 
 class Cluster_engraver : public Engraver
@@ -23,9 +24,9 @@ TRANSLATOR_DECLARATIONS(Cluster_engraver);
 
 private:
   Drul_array<Music*> reqs_drul_;
-  Pitch pitch_min, pitch_max;
-  Spanner *cluster;
-  SCM columns_scm;
+  Pitch pitch_min_, pitch_max_;
+  Spanner *cluster_;
+  SCM columns_scm_;
 };
 
 void reset_min_max (Pitch *pitch_min, Pitch *pitch_max)
@@ -40,8 +41,8 @@ void reset_min_max (Pitch *pitch_min, Pitch *pitch_max)
 
 Cluster_engraver::Cluster_engraver ()
 {
-  cluster = 0;
-  columns_scm = SCM_EOL;
+  cluster_ = 0;
+  columns_scm_ = SCM_EOL;
   reqs_drul_[LEFT] = reqs_drul_[RIGHT] = 0;
 }
 
@@ -52,11 +53,11 @@ Cluster_engraver::try_music (Music *m)
     {
       reqs_drul_[START] = 0;
       reqs_drul_[STOP] = 0;
-      if (cluster)
+      if (cluster_)
 	{
-	  cluster->suicide ();
-	  cluster = 0;
-	  columns_scm = SCM_EOL;
+	  cluster_->suicide ();
+	  cluster_ = 0;
+	  columns_scm_ = SCM_EOL;
 	}
     }
   else if (m->is_mus_type ("cluster-event"))
@@ -73,35 +74,30 @@ Cluster_engraver::process_music ()
 {
   if (reqs_drul_[STOP])
     {
-      if (!cluster)
+      if (!cluster_)
 	{
 	  reqs_drul_[STOP]->origin ()->warning ("can't find start of cluster");
 	}
       else
 	{
 	  Grob *bound = unsmob_grob (get_property ("currentMusicalColumn"));
-	  cluster->set_bound (RIGHT, bound);
-	  cluster->set_grob_property ("segments", columns_scm);
-	  typeset_grob (cluster);
-	  cluster = 0;
-	  columns_scm = SCM_EOL;
+	  cluster_->set_bound (RIGHT, bound);
 	}
-      reqs_drul_[STOP] = 0;
     }
   if (reqs_drul_[START])
     {
-      if (cluster)
+      if (cluster_)
 	{
 	  reqs_drul_[START]->origin ()->warning ("may not nest clusters");
 	}
       else
 	{
 	  SCM basicProperties = get_property ("Cluster");
-	  cluster = new Spanner (basicProperties);
-	  columns_scm = SCM_EOL;
+	  cluster_ = new Spanner (basicProperties);
+	  columns_scm_ = SCM_EOL;
 	  Grob *bound = unsmob_grob (get_property ("currentMusicalColumn"));
-	  cluster->set_bound (LEFT, bound);
-	  announce_grob (cluster, bound->self_scm ());
+	  cluster_->set_bound (LEFT, bound);
+	  announce_grob (cluster_, bound->self_scm ());
 	}
       reqs_drul_[START] = 0;
     }
@@ -110,40 +106,55 @@ Cluster_engraver::process_music ()
 void
 Cluster_engraver::start_translation_timestep ()
 {
-  reset_min_max (&pitch_min, &pitch_max);
+  reset_min_max (&pitch_min_, &pitch_max_);
 }
 
 void
 Cluster_engraver::stop_translation_timestep ()
 {
-  if (cluster)
+  if (cluster_)
     {
       SCM column_scm = get_property ("currentMusicalColumn");
       if (column_scm == SCM_EOL)
 	{
 	  programming_error("failed retrieving current column");
-	  return;
 	}
-
-      if (Pitch::compare (pitch_min, pitch_max) <= 0)
+      else
 	{
-	  int staff_position = pitch_min.steps ();
-	  SCM c0 = get_property ("centralCPosition");
-	  if (gh_number_p (c0))
-	    staff_position += gh_scm2int (c0);
-	  SCM segment = scm_list_n (column_scm,
-				    gh_int2scm (staff_position),
-				    pitch_min.smobbed_copy (),
-				    pitch_max.smobbed_copy (),
-				    SCM_UNDEFINED);
-	  segment = scm_list_n (segment, SCM_UNDEFINED);
-	  columns_scm = (columns_scm != SCM_EOL) ?
-	    gh_append2 (columns_scm, segment) : segment;
+	  if (Pitch::compare (pitch_min_, pitch_max_) <= 0)
+	    {
+	      Real y_bottom = 0.5 * pitch_min_.steps ();
+	      SCM c0 = get_property ("centralCPosition");
+	      if (gh_number_p (c0))
+		y_bottom += 0.5 * gh_scm2int (c0);
+	      else
+		programming_error ("Cluster_engraver: failed evaluating c0");
+	      Real y_top = y_bottom +
+		0.5 * (pitch_max_.steps () - pitch_min_.steps ());
+	      column_scm = Protected_scm (column_scm);
+	      SCM segment = scm_list_n (column_scm,
+					gh_double2scm (y_bottom),
+					gh_double2scm (y_top),
+					SCM_UNDEFINED);
+	      segment = scm_list_n (segment, SCM_UNDEFINED);
+	      columns_scm_ = (columns_scm_ != SCM_EOL) ?
+		gh_append2 (columns_scm_, segment) : segment;
+	      cluster_->set_grob_property ("segments", columns_scm_); // Urrgh!
+	    }
+	  else
+	    {
+	      /* This timestep is caused by a different voice of the
+		 same staff and hence should be ignored. */
+	    }
 	}
-      else
+
+      if (reqs_drul_[STOP])
 	{
-	  /* This timestep is caused by a different voice of the same
-	     staff and hence should be ignored. */
+	  reqs_drul_[STOP] = 0;
+	  cluster_->set_grob_property ("segments", columns_scm_);
+	  typeset_grob (cluster_);
+	  cluster_ = 0;
+	  columns_scm_ = SCM_EOL;
 	}
     }
 }
@@ -160,19 +171,19 @@ Cluster_engraver::acknowledge_grob (Grob_info info)
 	  if (nr && nr->is_mus_type ("note-event"))
 	    {
 	      Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
-	      if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd?
+	      if (Pitch::compare (pitch_min_, pitch_max_) > 0) // already init'd?
 		{
 		  // not yet init'd; use current pitch to init min/max
-		  pitch_min = pitch;
-		  pitch_max = pitch;
+		  pitch_min_ = pitch;
+		  pitch_max_ = pitch;
 		}
-	      else if (Pitch::compare (pitch, pitch_max) > 0) // new max?
+	      else if (Pitch::compare (pitch, pitch_max_) > 0) // new max?
 		{
-		  pitch_max = pitch;
+		  pitch_max_ = pitch;
 		}
-	      else if (Pitch::compare (pitch, pitch_min) < 0) // new min?
+	      else if (Pitch::compare (pitch, pitch_min_) < 0) // new min?
 		{
-		  pitch_min = pitch;
+		  pitch_min_ = pitch;
 		}
 	    }
 	}
diff --git a/lily/cluster.cc b/lily/cluster.cc
index f487cfb265..0e32dd14a8 100644
--- a/lily/cluster.cc
+++ b/lily/cluster.cc
@@ -132,10 +132,11 @@ Cluster::brew_molecule (SCM smob)
   Grob *me = unsmob_grob (smob);
 
   Spanner *spanner = dynamic_cast<Spanner*> (me);
-  if (!spanner) {
-    me->programming_error ("Cluster::brew_molecule(): not a spanner");
-    return SCM_EOL;
-  }
+  if (!spanner)
+    {
+      me->programming_error ("Cluster::brew_molecule(): not a spanner");
+      return SCM_EOL;
+    }
 
   Item *left_bound = spanner->get_bound (LEFT);
   Item *right_bound = spanner->get_bound (RIGHT);
@@ -149,7 +150,15 @@ Cluster::brew_molecule (SCM smob)
   bottom_points.clear ();
   top_points.clear ();
   SCM column_scm = SCM_EOL;
-  for (SCM columns_scm = me->get_grob_property ("segments");
+
+  SCM columns_scm = me->get_grob_property ("segments");
+  if (columns_scm == SCM_EOL)
+    {
+      me->warning ("junking empty cluster");
+      return SCM_EOL;
+    }
+
+  for (;
        columns_scm != SCM_EOL;
        columns_scm = ly_cdr (columns_scm)) {
     column_scm = ly_car (columns_scm);
@@ -162,31 +171,26 @@ Cluster::brew_molecule (SCM smob)
 	break; // ok, we have seen all columns
     column = unsmob_grob (col_scm);
     column_scm = ly_cdr (column_scm);
-    Real y = 0.5 * gh_scm2double (ly_car (column_scm));
-    column_scm = ly_cdr (column_scm);
-    Pitch *pitch_min = unsmob_pitch (ly_car (column_scm));
+    Real y_bottom = gh_scm2double (ly_car (column_scm));
     column_scm = ly_cdr (column_scm);
-    Pitch *pitch_max = unsmob_pitch (ly_car (column_scm));
-    Real height = 0.5 * (pitch_max->steps () - pitch_min->steps ());
+    Real y_top = gh_scm2double (ly_car (column_scm));
     Real x = column->relative_coordinate (common, X_AXIS);
     if (right_broken)
       x -= left_bound->relative_coordinate (common, X_AXIS);
-    bottom_points.push (Offset (x, y));
-    top_points.push (Offset (x, y + height));
+    bottom_points.push (Offset (x, y_bottom));
+    top_points.push (Offset (x, y_top));
   }
   if (right_broken)
     {
-      Real y = 0.5 * gh_scm2double (ly_car (column_scm));
+      Real y_bottom = gh_scm2double (ly_car (column_scm));
       column_scm = ly_cdr (column_scm);
-      Pitch *pitch_min = unsmob_pitch (ly_car (column_scm));
+      Real y_top = gh_scm2double (ly_car (column_scm));
       column_scm = ly_cdr (column_scm);
-      Pitch *pitch_max = unsmob_pitch (ly_car (column_scm));
-      Real height = 0.5 * (pitch_max->steps () - pitch_min->steps ());
       Real x =
 	right_bound->relative_coordinate (common, X_AXIS) -
 	left_bound->relative_coordinate (common, X_AXIS);
-      bottom_points.push (Offset (x, y));
-      top_points.push (Offset (x, y + height));
+      bottom_points.push (Offset (x, y_bottom));
+      top_points.push (Offset (x, y_top));
     }
   Molecule out = brew_cluster_piece (me, bottom_points, top_points);
   return out.smobbed_copy ();
diff --git a/lily/grob.cc b/lily/grob.cc
index 9aeb95f651..f11e52a4fc 100644
--- a/lily/grob.cc
+++ b/lily/grob.cc
@@ -700,9 +700,8 @@ void
 Grob::warning (String s)const
 {
   SCM cause = self_scm();
-  while (cause != SCM_EOL && !unsmob_music (cause))
+  while (Grob * g = unsmob_grob (cause))
     {
-      Grob * g = unsmob_grob (cause);
       cause = g->get_grob_property ("cause");
     }
 
diff --git a/lily/ligature-bracket-engraver.cc b/lily/ligature-bracket-engraver.cc
index 59e7687907..6f8d9e97cc 100644
--- a/lily/ligature-bracket-engraver.cc
+++ b/lily/ligature-bracket-engraver.cc
@@ -7,6 +7,8 @@
   
  */
 #include "ligature-engraver.hh"
+#include "note-column.hh"
+#include "tuplet-bracket.hh"
 #include "spanner.hh"
 #include "warn.hh"
 
@@ -14,6 +16,7 @@ class Ligature_bracket_engraver : public Ligature_engraver
 {
 protected:
   virtual Spanner *create_ligature_spanner ();
+  virtual void acknowledge_grob (Grob_info);
 
 public:
   TRANSLATOR_DECLARATIONS(Ligature_bracket_engraver);
@@ -33,10 +36,23 @@ Ligature_bracket_engraver::create_ligature_spanner ()
   return new Spanner (get_property ("LigatureBracket"));
 }
 
+void
+Ligature_bracket_engraver::acknowledge_grob (Grob_info info)
+{
+  if (ligature_)
+    {
+      if (Note_column::has_interface (info.grob_))
+	{
+	  Tuplet_bracket::add_column (ligature_, dynamic_cast<Item*> (info.grob_));
+	}
+      else Ligature_engraver::acknowledge_grob (info);
+    }
+}
+
 ENTER_DESCRIPTION(Ligature_bracket_engraver,
 /* descr */       "Handles Ligature_events by engraving Ligature brackets.",
-/* creats*/       "LigatureBracket",
+/* creats*/       "TupletBracket",
 /* accepts */     "ligature-event abort-event",
-/* acks  */      "ligature-head-interface rest-interface",
+/* acks  */      "ligature-head-interface rest-interface note-column-interface",
 /* reads */       "",
 /* write */       "");
diff --git a/scm/grob-description.scm b/scm/grob-description.scm
index 8c68a744dc..4e19b91a22 100644
--- a/scm/grob-description.scm
+++ b/scm/grob-description.scm
@@ -444,11 +444,18 @@
 
     (LigatureBracket
      . (
-	(width . 0.75)
-	(height . 0.5)
 	(ligature-primitive-callback . ,Note_head::brew_molecule)
-	(molecule-callback . ,Ligature_bracket::brew_molecule)
-	(meta . ((interfaces . (ligature-bracket-interface spanner-interface))))
+	(direction . 1)
+	(gap . 0.0)
+	(padding . 2.0)
+	(thickness . 1.6)
+	(edge-widen . (0.0 . 0.0))
+	(edge-height . (0.7 . 0.7))
+	(shorten-pair . (-0.2 . -0.2))
+	(before-line-breaking-callback . ,Tuplet_bracket::before_line_breaking)
+	(after-line-breaking-callback . ,Tuplet_bracket::after_line_breaking)
+	(molecule-callback . ,Tuplet_bracket::brew_molecule)
+	(meta .  ((interfaces . (tuplet-bracket-interface spanner-interface))))
 	))
 
     (LigatureHead