]> git.donarmstrong.com Git - lilypond.git/commitdiff
(get_paper_systems): uniq all_elements_ , to
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 May 2006 12:34:22 +0000 (12:34 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 27 May 2006 12:34:22 +0000 (12:34 +0000)
prevent duplicated broken items in output.

ChangeLog
lily/grob-array.cc
lily/include/grob-array.hh
lily/lily-guile.cc
lily/system.cc

index e79f324ba0513c5a109cc18638f1f64a6638f8c2..bebddfec67dede06d33fed1ebb3af2ae1483a0ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2006-05-27  Han-Wen Nienhuys  <hanwen@lilypond.org>
 
+       * lily/system.cc (get_paper_systems): uniq all_elements_ , to
+       prevent duplicated broken items in output.
+
        * scm/framework-eps.scm (output-classic-framework): only dump if
        dump-signatures is set.
 
index 7b462cbba241faed09cabda115c9c24cf71ad5b5..f9982f15149339041b4b9faabc2e7b280bbc4afb 100644 (file)
@@ -82,6 +82,12 @@ Grob_array::clear ()
   grobs_.clear ();
 }
 
+void
+Grob_array::uniq ()
+{
+  ::uniq (grobs_);
+}
+
 bool
 Grob_array::empty () const
 {
@@ -108,3 +114,4 @@ grob_list_to_grob_array (SCM lst)
     ga->add (unsmob_grob (scm_car (s)));
   return arr_scm;
 }
+
index 47580b38d168116e3605da9a75216356c9e1e721..f80c83632dd56d566f5082dc276db52a6f246290 100644 (file)
@@ -29,6 +29,7 @@ public:
   Grob *grob (vsize i) { return grobs_.at (i); }
   vsize size () const { return grobs_.size (); }
   bool empty () const;
+  void uniq ();
   void clear ();
   void add (Grob *x) { grobs_.push_back (x); }
   void set_array (vector<Grob*> const &src);
index 065ea388eedf3054a4f063adb5586350f1cf09f9..e44e47f4be27f6f30b64817b760191a678e4441f 100644 (file)
@@ -498,7 +498,9 @@ scm_default_compare (void const *a, void const *b)
   return pa < pb ? -1 : 1;
 }
 
-/*  Modify LST in place: qsort it.  */
+/*  Modify LST in place: qsort it.
+
+FIXME: unused, junk? */
 SCM
 ly_list_qsort_uniq_x (SCM lst)
 {
index 7e78eb2a119e561d4c87ac61dcfd1ff5308598d3..d1581b9e06eb8dab032e7b0f1e1f5f3998969da6 100644 (file)
@@ -163,27 +163,22 @@ System::get_paper_systems ()
 
   handle_broken_dependencies ();
 
-#if 0  /* FIXME: strange side effects.  */
-
   /* Because the this->get_property (all-elements) contains items in 3
      versions, handle_broken_dependencies () will leave duplicated
      items in all-elements.  Strictly speaking this is harmless, but
-     it leads to duplicated symbols in the output.  ly_list_qsort_uniq_x ()
-     makes sure that no duplicates are in the list.  */
-  for (int i = 0; i < line_count; i++)
+     it leads to duplicated symbols in the output.  uniq makes sure
+     that no duplicates are in the list.  */
+  for (vsize i = 0; i < broken_intos_.size (); i++)
     {
-      SCM all = broken_intos_[i]->get_object ("all-elements");
-      all = ly_list_qsort_uniq_x (all);
+      System *child = dynamic_cast<System*> (broken_intos_[i]);
+      child->all_elements_->uniq ();
     }
-#endif
 
   if (be_verbose_global)
     message (_f ("Element count %d.", count + element_count ()));
 
-  int line_count = broken_intos_.size ();
-  SCM lines = scm_c_make_vector (line_count, SCM_EOL);
-
-  for (int i = 0; i < line_count; i++)
+  SCM lines = scm_c_make_vector (broken_intos_.size (), SCM_EOL);
+  for (vsize i = 0; i < broken_intos_.size (); i++)
     {
       if (be_verbose_global)
        progress_indication ("[");
@@ -333,16 +328,20 @@ System::get_paper_system ()
   SCM exprs = SCM_EOL;
   SCM *tail = &exprs;
 
-  /* Output stencils in three layers: 0, 1, 2.  Default layer: 1. */
+  /* Output stencils in three layers: 0, 1, 2.  Default layer: 1.
+
+  FIXME: softcode this.
+  */
   for (int i = 0; i < LAYER_COUNT; i++)
-    for (vsize j = all_elements_->size (); j--;)
+    for (vsize j = 0; j < all_elements_->size (); j++)
       {
        Grob *g = all_elements_->grob (j);
+       if (robust_scm2int (g->get_property ("layer"), 1) != i)
+         continue;
+       
        Stencil st = g->get_print_stencil ();
 
-       /* Skip empty stencils and grobs that are not in this layer.  */
-       if (st.expr() == SCM_EOL
-           || robust_scm2int (g->get_property ("layer"), 1) != i)
+       if (st.expr() == SCM_EOL)
          continue;
 
        Offset o;
@@ -390,7 +389,7 @@ System::get_paper_system ()
       Interval staff_refpoints;
       staff_refpoints.set_empty ();
       extract_grob_set (this, "spaceable-staves", staves);
-      for (vsize i = staves.size (); i--;)
+      for (vsize i = 0; i < staves.size (); i++)
        {
          Grob *g = staves[i];
          staff_refpoints.add_point (g->relative_coordinate (this, Y_AXIS));