]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/rest-collision.cc
use trap to remove tmp directory on failure to avoid hiding mpost
[lilypond.git] / lily / rest-collision.cc
index fc8a4b401d2880347f687c2b908d62f0d5140f3b..8ba647e2019d8201d3698dbaa39cdd74f6671e90 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  Copyright (C) 1997--2012 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -146,13 +146,11 @@ Rest_collision::calc_positioning_done (SCM smob)
             rests[d]->warning (_ ("cannot resolve rest collision: rest direction not set"));
         }
 
-      Direction d = LEFT;
-      do
+      for (LEFT_and_RIGHT (d))
         vector_sort (ordered_rests[d], rest_shift_less);
-      while (flip (&d) != LEFT)
-        ;
 
-      do
+
+      for (LEFT_and_RIGHT (d))
         {
           if (ordered_rests[d].size () < 1)
             {
@@ -162,7 +160,6 @@ Rest_collision::calc_positioning_done (SCM smob)
               return SCM_BOOL_T;
             }
         }
-      while (flip (&d) != LEFT);
 
       Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS);
       common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS);
@@ -182,7 +179,7 @@ Rest_collision::calc_positioning_done (SCM smob)
                              2 * int (ceil (diff)));
         }
 
-      do
+      for (LEFT_and_RIGHT (d))
         {
           for (vsize i = ordered_rests[d].size () - 1; i-- > 0;)
             {
@@ -194,7 +191,6 @@ Rest_collision::calc_positioning_done (SCM smob)
                 Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2);
             }
         }
-      while (flip (&d) != LEFT);
     }
   else
     {
@@ -207,11 +203,12 @@ Rest_collision::calc_positioning_done (SCM smob)
       for (vsize i = 0; i < rests.size (); i++)
         {
           Grob *rcol = rests[i];
-          Direction dir = Note_column::dir (rcol);
+          Grob *rest = Note_column::get_rest (rcol);
+
+          Direction dir = get_grob_direction (rest);
           if (!dir)
-            continue;
+            dir = Note_column::dir (rcol);
 
-          Grob *rest = Note_column::get_rest (rcol);
           // Do not compute a translation for pre-positioned rests,
           //  nor count them for the "too many colliding rests" warning
           if (scm_is_number (rest->get_property ("staff-position")))